why I do not get printed "11111111111"? I am parsing asterisk ami output.
foreach($pieces as $val)
{
$pieces1 = explode("
", $val);
echo ("$pieces1[0]
");
if("$pieces1[0]" == "Response: Goodbye"){
echo("11111111111");
}
}
}
Asterisk Call Manager/1.1
Event: FullyBooted
Response: Success
Event: CoreShowChannel
Event: CoreShowChannel
Event: CoreShowChannelsComplete
Response: Goodbye
Most probably the input is CRLF-separated, not LF. Trim your exploded string of stray whitespace-like characters by changing it to:
$pieces1 = array_map('trim', explode("
", $val));
To properly debug issues like this always output debug data in a <pre>
field, and embed it in apostrophes or double quotes so you actually see stuff like this - in HTML all whitespace normally collapses so you don't notice.
Try:
if(trim($pieces1[0]) == "Response: Goodbye"){
echo("11111111111");
}