I have a function in cURL, its return is an indefinite amount of data, but its format is standard.
Return:
array(86) {
[0]=>
array(2) {
["value"]=>
int(1)
["data"]=>
string(27) "retorno 1"
}
[1]=>
array(2) {
["value"]=>
int(2)
["data"]=>
string(13) "retorno 2"
}
[2]=>
array(2) {
["value"]=>
int(3)
["data"]=>
string(87) "retorno 3"
}
[3]=>
array(2) {
["value"]=>
int(4)
["data"]=>
string(33) "retorno 4"
}
[4]=>
array(2) {
["value"]=>
int(5)
["data"]=>
string(28) "retorno 5"
}
}
I need to check if a variable is contained in the value string
and get the sequence array number.
I tried this way:
$content = curl_exec($ch);
$var= 'minha_variavel';
for ($i = 0; $i < $content; $i++)
{
$element = $content->string($i);
if (preg_match("#{$var}#i", $element))
{
return 'OK achei';
}
}
Unsuccessful