returning data in Array_filter

Asked

Viewed 47 times

1

Friends, in the code below I do the following:

$term = '422';

$data = json_decode($response);
$filtered = array_filter($data, function($item) use ($term) {
   return stripos($item->id, $term) !== false;
});

print_r($filtered);

And then I have this return below:

 Array ( [0] => stdClass Object ( [id] => 422 [filial] => 4 [name] => 
 COD. 069 30 Mb TRANSPORTE [nome_amigavel] => 30 Mb [mensalidade] => 
 1500.00 [desconto] => 0.00 [ativo] => 1 [tipo] => 3 [instalacao] => 
 1500.00 [bnd_up] => 0 [bnd_down] => 30000 ) ) 

How would I get it out of that return with an echo or print only ONE information !? example : 30 Mb

  • 3

    $Filtered[0]->friend_name

  • rs. Simple , Thanks Felipe !!!!

  • It would be possible to pick otherwise than by the array number [0] ! ?

  • Using reset: reset($filtered)->nome_amigavel

  • Thanks Marcelo, worked well !!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.