I have this code : 170-83746/2189
so to create a function, so that i can get the value before dash which is 170 and the value after dash which is 83746 and the value after slash which is 2189
I have read about regular expression in PHP but I couldn’t understand that thing
please help me
thanks for the solution, I come out with my own style using your help. Here is my code:
$number = "170-83746/2189";
function slice_trim($num, $symbol) {
if($symbol=='/')
$reg = '#/(\d+)#';
else
$reg = '#(\d+)-#';
preg_match($reg, $num, $match);
return str_replace($symbol,"",$match[0]);
}
echo slice_trim($number,"/");
To learn about regular expressions (which you really should), see http://regular-expressions.info.