這是我的第一篇文章,所以你好!檢索多維數組的結果
想知道我可以得到一點幫助,讓我的結果出這個MD陣列嗎?它給我意想不到的結果。我一直在尋求答案,但我不知道我應該問什麼問題..
這是陣列的相關部分的樣本[使用var_dump
]:
["Attendee"] => array(11)
{
["id"]=> int(148)
["firstname"]=> string(5) "dave"
["lastname"]=> string(6) "davey"`
}
這是我的foreach代碼獲得第一個和最後一個名字爲每個與會者:
foreach ($the_info_array['body']['Registrations'] as $registrations)
{
foreach ($registrations as $regvalue)
{
echo $regvalue['firstname'].」 「.$regvalue['lastname'];
}
echo 「<br>」;
}
此打印:
a a2 2 5 5 dave davey
a a2 2 5 5 scott davey
a a2 2 5 5 bill davey
等
,而不是我想要什麼,即:
dave davey
scott davey
bill davey
我要去哪裏錯了,&什麼多餘的字符?
在此先感謝社區給予的任何幫助!
編輯>>
奇怪的是,如果我改變回聲
echo $regvalue['firstname'];
它打印:
a25dave
a25scott
a25bill
和
回聲$ regvalue [ '姓名' ]。「」;
打印
a 2 5 dave
a 2 5 scott
a 2 5 bill
下面是完整的陣列減去一些記錄,我似乎無法發佈,許多人物:
array(3) {
["status"]=> string(2) "OK"
["status_code"]=> int(200)
["body"]=> array(1) {
["Registrations"]=> array(12) {
[0]=> array(15) {
["id"]=> int(148)
["status"]=> string(8) "approved"
["date_of_registration"]=> string(19) "2013-12-04 12:43:31"
["final_price"]=> int(0)
["code"]=> string(23) "529f2373bb7555.08033147"
["url_link"]=> string(0) ""
["is_primary"]=> bool(true)
["is_group_registration"]=> bool(true)
["is_going"]=> bool(true)
["is_checked_in"]=> bool(false)
["Event"]=> array(14) {
["id"]=> int(531) ["code"]=> string(15) "1-5298c3675e610"
["name"]=> string(21) "Recital 2014"
["description"]=> string(721) "The Description is this!"
["status"]=> string(6) "active"
["limit"]=> int(280)
["group_registrations_allowed"]=> bool(true)
["group_registrations_max"]=> int(50)
["active"]=> bool(true)
["member_only"]=> bool(false)
["virtual_url"]=> string(0) ""
["call_in_number"]=> string(0) ""
["phone"]=> string(0) ""
["metadata"]=> array(9) {
["default_payment_status"]=> string(10) "Incomplete"
["venue_id"]=> int(1)
["additional_attendee_reg_info"]=> string(1) "1"
["add_attendee_question_groups"]=> array(1) {
[1]=> string(1) "1" }
["date_submitted"]=> string(10) "29/11/2013"
["event_hashtag"]=> string(0) ""
["event_format"]=> string(0) ""
["event_livestreamed"]=> string(0) ""
[""]=> string(0) "" } }
["Attendee"]=> array(11) {
["id"]=> int(219)
["firstname"]=> string(5) 「dave」
[「lastname」]=> string(7) "davis"
["address"]=> string(13) "10 The Street"
["address2"]=> string(0) ""
["city"]=> string(8) "The City"
["state"]=> string(10) "The County"
["country"]=> string(0) ""
["zip"]=> string(6) "BN66YY"
["email"]=> string(17) "[email protected]"
["phone"]=> string(12) "012736654432" }
["Transaction"]=> array(9) {
["id"]=> int(219)
["timestamp"]=> string(19) "2013-12-23 00:26:22"
["total"]=> float(132.6)
["amount_paid"]=> int(0)
["status"]=> string(10) "incomplete"
["details"]=> string(0) ""
["tax_data"]=> string(0) ""
["session_data"]=> string(0) ""
["payment_gateway"]=> string(19) "Credit/Debit Card" }
["Datetime"]=> array(8) {
["id"]=> int(0) ["is_primary"]=> bool(true)
["event_start"]=> string(19) "2014-01-11 00:00:00"
["event_end"]=> string(19) "2014-01-11 00:00:00"
["registration_start"]=> string(19) "2012-08-12 16:00:00"
["registration_end"]=> string(19) "2014-01-10 16:00:00"
["limit"]=> int(280) ["tickets_left"]=> int(274) }
["Price"]=> array(9) {
["id"]=> int(0)
["name"]=> string(0) ""
["amount"]=> int(0)
["description"]=> string(0) ""
["limit"]=> int(9999999)
["remaining"]=> int(999999)
["start_date"]=> NULL
["end_date"]=> NULL
["Pricetype"]=> array(8) {
["id"]=> int(1)
["name"]=> string(10) "Base Price"
["is_member"]=> bool(false)
["is_discount"]=> bool(false)
["is_tax"]=> bool(false)
["is_percent"]=> bool(false)
["is_global"]=> bool(true)
["order"]=> int(0) } } } } } }
//另外,不知道是否有關,但陣列來自一個json解碼最初
你可以張貼陣列? – sas
當我們看不到數組時,它不是真的可以看到錯誤,你可以將完整的數組添加到問題中嗎? –
請發佈陣列。 –