Linked Questions

158 votes
14 answers
459k views

I fetch post_id from postmeta as: $post_id = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE (meta_key = 'mfn-post-link1' AND meta_value = '". $from ."')"); when i try print_r($...
Dinesh's user avatar
  • 4,114
74 votes
24 answers
217k views

I have an array which is multidimensional for no reason /* This is how my array is currently */ Array ( [0] => Array ( [0] => Array ( [plan] => basic ...
CuriousMind's user avatar
  • 34.3k
168 votes
4 answers
240k views

Let's assume I have the following multidimensional array (retrieved from MySQL or a service): array( array( [id] => xxx, [name] => blah ), array( [id] =>...
ifaour's user avatar
  • 38.1k
70 votes
4 answers
93k views

I tested inline anonymous function with array_map here and it worked but when I tried same with $user_meta it is not working. $user_meta = Array ( [interest] => Array ( [0] => Array ) [type] =&...
B L Praveen's user avatar
  • 2,008
45 votes
5 answers
118k views

I have a nested array in which I want to display a subset of results. For example, on the array below I want to loop through all the values in nested array[1]. Array ( [0] => Array ( [0] =>...
noangel's user avatar
  • 553
27 votes
4 answers
65k views

I have an array as follows: $arr1 = array( 0 => array( 'name' => 'tom', 'age' => 22 ), 1 => array( 'name' => 'nick', 'age' => 18 ) ); However I want to ...
newbtophp's user avatar
  • 649
27 votes
8 answers
18k views

I'm sure this question has been asked before, my apologies for not finding it first. The original array: [0] => Array ( [categoryId] => 1 [eventId] => 2 [...
Caleb Gray's user avatar
  • 3,127
18 votes
7 answers
44k views

Is there a cleaner way than foreach to get an array of all "label" values? $methods[0]['label'] = 'test'; $methods[0]['nr'] = 99; $methods[1]['label'] = 'whatever'; $methods[1]['nr'] = 10; ...
powtac's user avatar
  • 41.1k
31 votes
2 answers
32k views

I have a common pattern which Im sure there must be a built-in array function in PHP to handle but just can't see it. I have multiple arrays such as the following: $testArray = array ( '...
Marty Wallace's user avatar
15 votes
7 answers
22k views

Here's a section my multidimensional array: Array ( [0] => Array ( [0] => Height [1] => 40 ) [1] => Array ( [0] => Weight [1] => 15 ) [2] => Array ( [0] => Ctr_Percent [1] =...
Norse's user avatar
  • 5,757
9 votes
5 answers
32k views

I'm trying to exclude foreach-loops and refactor them with array functions. I was under the assumption the code below would give me a result with all first items from the source array. <?php $...
Ben's user avatar
  • 11.3k
12 votes
2 answers
46k views

Is there any way to get all values in one array without using foreach loops, in this example? <?php $foo = array(["type"=>"a"], ["type"=>"b"], ["type"=>"c"]); The output I need is array(...
iOi's user avatar
  • 413
3 votes
7 answers
8k views

I have an array that looks $articles = array([0] => array('title' => 'When ....', 'description' => '....', 'created' => '...
Rick 's user avatar
  • 33
8 votes
6 answers
24k views

This is more a request for a quick piece of advice as, I find it very hard to believe there isn't a native function for the task at hand. Consider the following: array => (0) => array("id" =&...
Simon's user avatar
  • 1,004
7 votes
3 answers
13k views

I have an multidimensional array which includes IDs and URLs. I would like to output the URLs only. $abstract_details = array( array( 'id' => ...
Reza's user avatar
  • 523

15 30 50 per page
1
2 3 4 5
9