我编写了一个显示给定输出的SQL程序。如何使用foreach循环访问php中的数据?
Array
(
[0] => Array
(
[0] => Array
(
[vehical_profile_id] => 1
[chasis_number] => 123
[vehicle_engine_number] => a123
[rto_regis_number] => a123
[model_number] => a123
[vehicle_color] => red
[vehicle_production_year_month] => june 2012
[owner_first_name] => avinash
[owner_middle_name] => prakash
[owner_last_name] => dhanke
[owner_father_name] => prakash dhanke
[owner_gender] => male
[owner_blood_group] => AB+
[owner_dob] => 1990-07-07
[entity_address] => wadi
[entity_local_area] => navneet nagar
[entity_city] => nagpur
[entity_state] => mh
[entity_country] => india
[entity_pincode] => 440023
[mobile] => 973044444
[landline] =>
[email] => prajakta@gmail.com
[vehicle_service_profile_id] => 1
[vehicle_id] => 1
[vehicle_service_in_date] => 2014-11-19
[vehicle_service_out_date] => 0000-00-00
[vehicle_service_status] => NOT DONE
[vehicle_service_job_card_no] => job123
[vehicle_service_receipt_no] => r123
[vehicle_service_total_cost] => 5000
)
)
[1] => Array
(
[0] => Array
(
[vehicle_service_details_id] => 1
[vehicle_service_profile_id] => 1
[vehicle_service_work_code] => OILCHANGE
[vehicle_service_work_status] => NOT DONE
[vehicle_service_work_cost] => 5000
)
[1] => Array
(
[vehicle_service_details_id] => 2
[vehicle_service_profile_id] => 1
[vehicle_service_work_code] => BREAKSHOES
[vehicle_service_work_status] => NOT DONE
[vehicle_service_work_cost] => 2000
)
[2] => Array
(
[vehicle_service_details_id] => 3
[vehicle_service_profile_id] => 1
[vehicle_service_work_code] => HEADLIGHT
[vehicle_service_work_status] => NOT DONE
[vehicle_service_work_cost] => 1000
)
)
)
答案 0 :(得分:0)
$FinalArray=array();
foreach($array as $valueArrayone){
foreach($valueArrayone as $valueArrayTwo){
// valueArrayTwoWILL BE THE 3rd nested array, this is how you can access it but you need to take care of the nesting
$finalArray[]= $valueArrayTwo; <--- you can assign that array to final array and can iterate over it
}
}
print_r($finalArray);
我希望它能顺利运作。