Find a Word after a particular word
I am not so expert in the regular expression. I have created a function to
find out a particular word after a first match word from an array. the
code is
$searchkey=array('CURRENT BALANCE RS.', 'balance rs.');
$smsdata = "SUCCESSFUL ON 20/08/2013 AT 06:44:38 AM. CURRENT BALANCE RS.
11192.75. REF 1210943279.";
function get_details($searchkey, $smsdata){
foreach($searchkey as $key){
$result=preg_match_all("/(?<=(".$key."))(\s\w*)/",$smsdata,$networkID);
$myanswer = @$networkID[0][0];
}
return $myanswer;
}
I am using this function to find out other words also. and it is working
find for any other words except the decimal value. Here in my example code
the return value is 11192 but i would like to get with decimal as 11192.75
Please rectify my error.
thanks
No comments:
Post a Comment