I want to use preg_match() too find the last word of a string:
I already have this:
Code: Select all
$content='just a string';
$pattern = '/[\w]+$/';
preg_match($pattern, $content, $result);
echo $result[0];
Code: Select all
$content='just a string';
$pattern = '/[\w]+$/';
preg_match($pattern, $content, $result);
echo $result[0];
Code: Select all
explode(' ',$content);
Code: Select all
$content='just a string';
$pattern='/[a-z]+(?=[^a-z]*$)/i';
preg_match($pattern, $content, $result);