My data is in this format. I want it without wishlist_id, means simple values. How to change the array values?
Array (
[0] => Array ( [wishlist_id] => 35 )
[1] => Array ( [wishlist_id] => 36 )
[2] => Array ( [wishlist_id] => 38 )
[3] => Array ( [wishlist_id] => 39 )
[4] => Array ( [wishlist_id] => 42 )
[5] => Array ( [wishlist_id] => 43 )
[6] => Array ( [wishlist_id] => 45 )
[7] => Array ( [wishlist_id] => 48 )
[8] => Array ( [wishlist_id] => 50 )
[9] => Array ( [wishlist_id] => 52 )
[10] => Array ( [wishlist_id] => 53 )
[11] => Array ( [wishlist_id] => 55 )
[12] => Array ( [wishlist_id] => 57 )
[13] => Array ( [wishlist_id] => 59 )
[14] => Array ( [wishlist_id] => 60 )
[15] => Array ( [wishlist_id] => 63 )
[16] => Array ( [wishlist_id] => 66 )
[17] => Array ( [wishlist_id] => 67 )
[18] => Array ( [wishlist_id] => 69 )
[19] => Array ( [wishlist_id] => 70 )
[20] => Array ( [wishlist_id] => 73 )
[21] => Array ( [wishlist_id] => 75 )
[22] => Array ( [wishlist_id] => 76 )
[23] => Array ( [wishlist_id] => 78 )
[24] => Array ( [wishlist_id] => 80 )
[25] => Array ( [wishlist_id] => 83 )
[26] => Array ( [wishlist_id] => 85 )
)
7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Jan 4, 2016 at 10:27
Sumit Aggarwal
1471 gold badge2 silver badges7 bronze badges
2 Answers 2
Try this:
echo '<pre>';
$twoDimensionalArray = array(array('wishlist_id' => 35),array('wishlist_id' => 40),array('wishlist_id' => 50));
$oneDimensionalArray = array_map('current', $twoDimensionalArray);
print_r($oneDimensionalArray);
answered Jan 4, 2016 at 11:32
Abdul
9,7291 gold badge22 silver badges44 bronze badges
get values by
foreach ($wardrobe_ids as $item){
echo $wishlist = $item[wishlist_id];
}
I hope this will help you.
answered Jan 4, 2016 at 10:32
Denish Vachhani
4,5523 gold badges17 silver badges47 bronze badges
-
$wardrobe_ids = $mysql->getAll("Select
wishlist_idfromcustomer_wishlistswheretype='wardrobe'"); print_r($wardrobe_ids); I am using thisSumit Aggarwal– Sumit Aggarwal2016年01月04日 10:35:27 +00:00Commented Jan 4, 2016 at 10:35 -
'print_r($wardrobe_ids->getData());' use this.Denish Vachhani– Denish Vachhani2016年01月04日 10:37:38 +00:00Commented Jan 4, 2016 at 10:37
-
its giviing me errorSumit Aggarwal– Sumit Aggarwal2016年01月04日 10:40:00 +00:00Commented Jan 4, 2016 at 10:40
-
check updated answer this will help you.Denish Vachhani– Denish Vachhani2016年01月04日 10:52:12 +00:00Commented Jan 4, 2016 at 10:52
-
i need it without loopSumit Aggarwal– Sumit Aggarwal2016年01月04日 10:54:02 +00:00Commented Jan 4, 2016 at 10:54
default