Adsense
Popular Posts
- Code update from PHP 7.4 to PHP 8.1 - PhpSpreadsheet
- MySQL workbench -"Could not decrypt password cache"
- Code update from PHP 7.4 to PHP 8.1 - Worksheet/Iterator.php
- Rendering HTML tags inside textarea
- axios handle blob type data
- Unix Utils and wget in Windows
- increase mysql query speed
- Setup vi syntax for PHP
- Get WAMP running on EC2
- EXCEL return to the next line in the same cell
Friday, November 7, 2014
PHP, separate string by any space or comma, lowercaser and timestamp in PHP and MySQl
PHP, separate string by any space or comma using regular expression
// split the phrase by any number of commas or space characters,
// which include " ", \r, \t, \n and \f
$course_pieces = preg_split("/[\s,]+/", trim($course));
If you use explode, you can only separate by one space:
$course_pieces = explode(" ", trim($course));
In PHP, to convert to lower case:
$course_subject = strtolower($course_pieces[0]);
$course_number = $course_pieces[1];
While in MySQL, we use LOWER
for example
$oplCondition = " AND LOWER(FirstName) LIKE LOWER('%".$firstname))."%')";
MySQL TIMESTAMP date type, corresponding to PHP function
date("Y-m-d H:i:s")
Labels:
php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment