Forum Moderators: coopster
Sucess was the xml response
<result>1</result>
the code to parse was
list($a,$b)=split("<result>",$full_arr['response'][$key],2);
list($c,$d)=split("</result>",$b,2);
if ($c==1) {$succ="SUCCESS"; $no_of_succ++;}
else $succ="FAILED";
The error was <result>0</result>
The sucessful response now is
ID: # (where # is the id of the message)
And error is Err: 601
list($a,$b)=split("<result>",$full_arr['response'][$key],2);
list($c,$d)=split("</result>",$b,2);
if ($c==1) {$succ="SUCCESS"; $no_of_succ++;}
else $succ="FAILED";
This would match only <result>0</result> or <result>1</result>
if(preg_match("/<result>([0-1]{1})<\/result>/",$xml_repsonse,$store_number)) {
$the_id_number=$store_number[1];
// The rest of your code here.
}
else {
echo $error="There was no number between <result> & </result>";
}
I just expanded it to match any number between the <result> tags.
If you need the tags stored, use something like:
preg_match("/(<result>([0-9]+)<\/result>)/",$xml_repsonse,$store_number));
if($store_number[2]!='') {
$the_id_number=$store_number[2];
echo "There was a number between <result> & </result> the full string is:<br />";
echo $store_number[1];
// The rest of your code here.
}
else {
echo $error="There was no number between <result> & </result>";
}
The code I posted already worked based on parsing the text between the word "response". However the sucessful response now isID: # (where # is the id of the message)
I'm not sure about the error number, but it seems to me you will need to match and store the value (or at least check for a numerical match) between the response tags... What I posted does that. I'll leave it to you or someone else who has a better idea than I do.
Maybe intval() will help you out, because it seems you are checking for 1 or 0 and not 'any number except 0' as you will need to do (IMO) to ensure an accurate match... I'll leave it to you and others from here.
Sorry I couldn't be of more help.
Like I said, I'm clueless as to what you're looking for and apparently all you've posted is the old code without posting what you're actually searching through to find the ID now. Are you even searching anything?
Do you mean you get ID: NUMBER?
Then just modify my regular expression:
if(preg_match("/^ID:\s?[0-9]+$/"),$what_ever_variable_you_are_using) {
echo "There's a number here.";
}