Save yourself the headache and just include Phpstr:
require 'phpstr.php';
Return a match
str('There are 23 people reading this blog')->match('/\d+/');
Substitution
str('all of the es')->gsub('/e/', 'y');
Scan will return an array of matches
str('010 202 312 332')->scan('/\d+/');
Split will return an array of tokens
str('010 202-312 332')->split('/\s/');
Isn't that so much easier?
View the project or download the source.
No comments:
Post a Comment