I have an array like this. I get this from a server's response :
So sometimes the array is like this :
$array =
Array
(
[0] => Message: Thanks for all
[1] => Response: Goodbye
[2] =>
[3] => inactive
[4] => active call
[5] => active channels
[6] => Hello
[7] => Hi
[8] => yes
[9] => no
)
and sometimes it's like this :
$array =
Array
(
[0] => Message: Thanks for all
[1] => Response: Goodbye
[2] =>
[3] => SessionTV: 2019-06-24T17:29:53.925+0530
[4] => SessionTV: 2019-06-24T17:29:53.925+0530
[5] => SessionTV: 2019-06-24T17:29:53.925+0530
[6] => Event: 0
[7] => active channels
[8] => Hello
[9] => Hi
[10] =>
)
This is what I tried :
if (in_array("Event:", $array))
{
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
}
else
{
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
array_shift($minarr);
}
But this doesn't work.
Expected output in both cases is :
Array
(
[0] => Hello
[1] => Hi
[2] => yes
[3] => no
)
and
Array
(
[0] => Hello
[1] => Hi
[2] =>
)
So basically I just shift some rows from the array if it contains the string Event: and shift some other rows if it doesn't contain the string Event: .
How do I search for a string in an array like this?
Event:doesn't exist in the first type of the array. So how did you come up with it's result like that. Can you elaborate?active channelsvalue?Event:in it or not? Is that right??