Loop through multidimensional array database response to extract data PHP -
i want loop though array below , display html table data "type" in 1 column , data "description" in other.
how do in php?
below print_r of array.
array ( [0] => array ( [id] => 1 [type] => printing , scanning facilities [has_amenity] => 1 [description] => please keep self less 50 pages per day! [owner_desk_id] => 3 [created_at] => 2013-10-07 05:14:06 [updated_at] => 2013-10-07 05:14:06 ) [1] => array ( [id] => 2 [type] => climate control [has_amenity] => 1 [description] => have heating winter no air conditioning. byo fan. [owner_desk_id] => 3 [created_at] => 2013-10-07 16:30:56 [updated_at] => 2013-10-07 16:30:56 ) )
here go:
$i = 0; while(isset(yourarray[$i])) { foreach(yourarray[$i] $key => $value) { if(($key == "value") || ($key == "description")) $resultarray[$i][$key] = $value; //store in resultarray or can print html depending on want } $i++; }
above kind of looping you'll need extract specific data array.
Comments
Post a Comment