Solo cambia la condición a
=== entre $item y $search
Código PHP:
Ver original$array = [
0 =>
[
"timestamp" => "1337966810",
"category" =>
[
0 => "survey78399_",
1 => "transactional",
],
"event" => "delivered",
],
1 =>
[
"timestamp" => "1337966855",
"category" =>
[
0 => "survey78399",
1 => "transactional",
],
"event" => "spam",
],
2 =>
[
"timestamp" => "1337966899",
"category" =>
[
0 => "survey8888",
1 => "transactional",
],
"event" => "open",
],
3 =>
[
"timestamp" => "1337966899",
"category" => "survey78399",
"event" => "open",
],
4 =>
[
"sg_event_id" => "sendgrid_internal_event_id",
"sg_message_id" => "sendgrid_internal_message_id",
"ip" => "255.255.255.255",
"useragent" => "Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53",
"event" => "click",
"timestamp" => 1249948800,
"url" => "http://yourdomain.com/blog/news.html",
"url_offset" =>
[
"index" => 0,
"type" => "html",
],
"unique_arg_key" => "unique_arg_value",
"category" =>
[
0 => "category1",
1 => "category2"
],
"newsletter" =>
[
"newsletter_user_list_id" => 10557865,
"newsletter_id" => 1943530,
"newsletter_send_id" => 2308608,
],
"asm_group_id" => 1,
]
];
$search = 'survey78399';
$callback = function($item) use (&$callback, &$search) {
}else {
return $item === $search;
}
};
print_r($filtered); // imprime solo key 1 y 3 del arreglo original /*
Array
(
[1] => Array
(
[timestamp] => 1337966855
[category] => Array
(
[0] => survey78399
[1] => transactional
)
[event] => spam
)
[3] => Array
(
[timestamp] => 1337966899
[category] => survey78399
[event] => open
)
)
*/