Skip to content
Advertisement

Quick way to get the value from array with another array giving condiition

Lets say there is an array $filter_from_array_id = array(2,8,52,45,7)

And then there is another array

JavaScript

I want a result something like these array([0] => array(id=> 8,name => 'data-ryhryh'),

You see the point, id is filtered.

I will get the result through looping but if the main array is larger then it can consume time , I wonder if there is a short way than looping through all.

I would also want to know if php has something inbuilt for this one or anything close.

Advertisement

Answer

Create an associative array from $main_array so you don’t have to loop to find the IDs.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement