-1
Array ( [err] => [num] => 1 [result] => Array ( [0] => Array ( [0] => 85 [proj_id] => 85 [1] => Automatic Mobile Alert System For Lethal Gas Detection [proj_item_title] => Automatic Mobile Alert System For Lethal Gas Detection [2] => GSM PROJECTS [proj_category] => GSM PROJECTS [3] => 5000 [actual_price] => 5000 [4] => 4000 [discount_price] => 4000 [5] => 5 [rating] => 5 [6] => automatic-mobile-alert-system-for-lethal-gas-detection [friendly_url] => automatic-mobile-alert-system-for-lethal-gas-detection [7] => gsnrtmccfoqqkgb8qs2ni5hud36c032j [session_id] => gsnrtmccfoqqkgb8qs2ni5hud36c032j [8] => 85 [9] => 2017-01-20 [date_added] => 2017-01-20 [10] => 1 [qty] => 1 ) ) ) 

I need to access elements from the array "result". How can I access them. Please help me.

CodeForGood
  • 767
  • 7
  • 30

2 Answers2

0

echo $array['result'][0][0]

Will return 85

$result = $array['result'][0]

Will give you a nice way to save the Result array into another Array.

So you can do

$result[0] //Returns 85 again

Moe
  • 4,744
  • 7
  • 28
  • 37
0

Your $data['result'] is an array so you can simply loop over the elements

foreach($data['result'] as $result) {
   var_dump($result);
   echo $result[0]; 
   echo $result['proj_item_title'];
   echo $result['proj_id']; //etc
}
Robert
  • 19,800
  • 5
  • 55
  • 85
  • Thank you Robert, Moe and Siddiqui for the help. I am grateful for the time you spent on my question. Time is precious. – CodeForGood Jan 21 '17 at 06:03