nitiphone2021 Posted March 15, 2021 Share Posted March 15, 2021 Dear All, How can I get information that return from this array Array ( [0] => Array ( [id] => 5 [t_test_date] => 2021-02-11 [t_test_number] => 1 [t_uid] => 202102110001 [t_test_type] => 1 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 0 [t_test_time] => 2021-02-11 11:39:00 [t_report_date] => [p_first_name] => tesdt [p_last_name] => tesdt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 11:40:18 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 11:39 ) [1] => Array ( [id] => 7 [t_test_date] => 2021-02-11 [t_test_number] => 3 [t_uid] => 202102110003 [t_test_type] => 2 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 1 [t_test_time] => 2021-02-11 18:38:00 [t_report_date] => [p_first_name] => Hhh [p_last_name] => Tttt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 18:38:51 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 18:38 ) ); Quote Link to comment https://forums.phpfreaks.com/topic/312297-get-information-from-array/ Share on other sites More sharing options...
Barand Posted March 15, 2021 Share Posted March 15, 2021 Use the successive keys. $value = $array[$recordNo][$fieldname]; EG $date = $array[0]['t_test_date']; // 2021-02-11 Quote Link to comment https://forums.phpfreaks.com/topic/312297-get-information-from-array/#findComment-1585102 Share on other sites More sharing options...
NotionCommotion Posted March 15, 2021 Share Posted March 15, 2021 (edited) 12 minutes ago, nitiphone2021 said: Dear All, How can I get information that return from this array Array ( [0] => Array ( [id] => 5 [t_test_date] => 2021-02-11 [t_test_number] => 1 [t_uid] => 202102110001 [t_test_type] => 1 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 0 [t_test_time] => 2021-02-11 11:39:00 [t_report_date] => [p_first_name] => tesdt [p_last_name] => tesdt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 11:40:18 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 11:39 ) [1] => Array ( [id] => 7 [t_test_date] => 2021-02-11 [t_test_number] => 3 [t_uid] => 202102110003 [t_test_type] => 2 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 1 [t_test_time] => 2021-02-11 18:38:00 [t_report_date] => [p_first_name] => Hhh [p_last_name] => Tttt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 18:38:51 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 18:38 ) ); What information do you wish to obtain from your array? Assuming your array is named $yourArray, then you can access elements in it using something like $yourArray[0] which will also be an array or $yourArray[0]['id'] which will return 5. Try it out and use either print_r() or var_dump() to view the results. Edited March 15, 2021 by NotionCommotion Quote Link to comment https://forums.phpfreaks.com/topic/312297-get-information-from-array/#findComment-1585103 Share on other sites More sharing options...
nitiphone2021 Posted March 15, 2021 Author Share Posted March 15, 2021 6 minutes ago, NotionCommotion said: What information do you wish to obtain from your array? Assuming your array is named $yourArray, then you can access elements in it using something like $yourArray[0] which will also be an array or $yourArray[0]['id'] which will return 5. Try it out and use either print_r() or var_dump() to view the results. Sorry, my question is not clear. I want to loop to get all information from the array. it's information from database 2 rows Quote Link to comment https://forums.phpfreaks.com/topic/312297-get-information-from-array/#findComment-1585104 Share on other sites More sharing options...
nitiphone2021 Posted March 15, 2021 Author Share Posted March 15, 2021 10 minutes ago, Barand said: Use the successive keys. $value = $array[$recordNo][$fieldname]; EG $date = $array[0]['t_test_date']; // 2021-02-11 How can I use loop to get all information? it is information from database query and it has 2 rows Quote Link to comment https://forums.phpfreaks.com/topic/312297-get-information-from-array/#findComment-1585106 Share on other sites More sharing options...
Solution Barand Posted March 15, 2021 Solution Share Posted March 15, 2021 foreach (array as $recno => $record) { echo "<h3>Record $recno</h3>"; foreach ($record as $field => $value) { echo "$field : $value<br>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/312297-get-information-from-array/#findComment-1585107 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.