Adsense
Popular Posts
- Install APXS in Redhat Linux
- MySQL workbench -"Could not decrypt password cache"
- Transfer modules between sites
- JavaScript, remove trailing insignificant zeros after toFixed function
- Set Windows path command line
- datatable order by nunmeric
- MySQL date created and date modified
- super(props) in React
- PHP, dump varailbes in a format way
- React: connect(mapStateToProps, mapDispatchToProps)
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