Extract words between two words Using Preg Match
we need the word between "modules" and "widgets".
Please use this code.
Code :
$str = "addons/modules/featured/widgets/single/";
//$str = str_replace("/","-",$str);
preg_match('/modules\/(.*?)\/widgets/', $str, $match);
echo "<pre>";
print_r($match);
echo "</pre>";
Output :
Array ( [0] => modules/featured/widgets [1] => featured )
No comments:
Post a Comment