0

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 )
)    
0

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);
| improve this answer | |
0

get values by

foreach ($wardrobe_ids as $item){
        echo $wishlist = $item[wishlist_id];
    }

I hope this will help you.

| improve this answer | |
  • $wardrobe_ids = $mysql->getAll("Select wishlist_id from customer_wishlists where type='wardrobe'"); print_r($wardrobe_ids); I am using this – Sumit Aggarwal Jan 4 '16 at 10:35
  • 'print_r($wardrobe_ids->getData());' use this. – Denish Vachhani Jan 4 '16 at 10:37
  • its giviing me error – Sumit Aggarwal Jan 4 '16 at 10:40
  • check updated answer this will help you. – Denish Vachhani Jan 4 '16 at 10:52
  • i need it without loop – Sumit Aggarwal Jan 4 '16 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.