Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ถามเกี่ยวกับการดึงข้อมูลจาก JSON Xml Array มาเป็นตัวแปรครับ



 

ถามเกี่ยวกับการดึงข้อมูลจาก JSON Xml Array มาเป็นตัวแปรครับ

 



Topic : 096091

Guest




สวัสดีครับคือผมได้ทำตัวรับส่งค่าผ่าน xml json และได้ค่ากลับมาดังนี้

Code
[products] => Array
(
[@attributes] => Array
(
[count] => 18536
)

[product] => Array
(
[0] => Array
(
[@attributes] => Array
(
[category] => 7660
[price_min] => 258.88
[image_url_large] => http://images.thesource.ca/images/Online/80/8005119l.jpg
[description] => Clear Motion Rate of 60Experience sharp picture quality even when you are watching fast-moving images like sports or action movies. Clear Motion Rate was developed to accurately measure how well an LCD or LED TV can depict fast-moving images. Previously motion-clarity was calculated by the frame refresh rate alone. But CMR offers a more complete measure by calculating 3 factors: frame refresh rate image processor speed and backlight technology. LED TVs with a CMR of 60 -120 can display action-packed movement with sharp detail and vivid contrast while eliminating image distortion. Wide Color Enhancer PlusWide Color Enhancer Plus allows you to see picture color the way the director originally intended. Witness the entire RGB spectrum brought to life on your screen to bring you exceptionally vibrant yet natural-looking images faithful to the director's original intent. ENERGY STAR V 5.3 CompliantGo green and save the planet. This Samsung TV not only meets ENERGY STAR requirements; it exceeds them. This means: More energy savings Lower utility bills Leaving a smaller carbon footprint on the environment See energystar.gov for more information ConnectShare trade; MovieConnectShare Movie lets you watch videos play music or view photos from a USB connection without needing to use a PC or special equipment. Simply plug your USB device or drive directly into your Samsung TV's USB port and watch on the big screen with friends and family. HDMIGet superior picture and sound from your HD source. The High-Definition Multimedia Interface (HDMI) is a digital connection that can transmit HD video and audio over a single cable. Use it to optimize the image quality when you connect your TV to high-definition sources such as HD cable TV satellite receiver or Blu-ray player.
[price_max] => 449.99
[name] => Samsung 32" Class 720p LED HDTV UN32EH4003 Black
[id] => 26950189
[offer_count] => 21
[image_url_small] => http://www.onecall.com/media/catalog/product/S/a/Samsung-UN32EH4003.jpg
[brand] => 31186
)

)
)
)


ซึ่งที่ผมอยากจะดึงเพื่อนำมาใช้งานแบบ
$name
$brand

ผมจะต้องทำอย่างไรครับเพื่อดึงค่าใน array ด้านบนนี้มาครับ



Tag : PHP, JAVA, JSP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-06-04 19:03:59 By : Mr.S View : 950 Reply : 3
 

 

No. 1



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ถ้าดูจากข้อมูลแล้ว มันเป็น array หมดเลย ไม่ใช่ object พวก simple_xml

คงต้องเข้าถึงแบบทีละขั้นอ่ะครับ

Code
[products] => Array ( [@attributes] => Array ( [count] => 18536 ) [product] => Array ( [0] => Array ( [@attributes] => Array ( [category] => 7660 [price_min] => 258.88 [image_url_large] => http://images.thesource.ca/images/Online/80/8005119l.jpg [description] => Clear Motion Rate of 60Experience sharp picture quality even when you are watching fast-moving images like sports or action movies. Clear Motion Rate was developed to accurately measure how well an LCD or LED TV can depict fast-moving images. Previously motion-clarity was calculated by the frame refresh rate alone. But CMR offers a more complete measure by calculating 3 factors: frame refresh rate image processor speed and backlight technology. LED TVs with a CMR of 60 -120 can display action-packed movement with sharp detail and vivid contrast while eliminating image distortion. Wide Color Enhancer PlusWide Color Enhancer Plus allows you to see picture color the way the director originally intended. Witness the entire RGB spectrum brought to life on your screen to bring you exceptionally vibrant yet natural-looking images faithful to the director's original intent. ENERGY STAR V 5.3 CompliantGo green and save the planet. This Samsung TV not only meets ENERGY STAR requirements; it exceeds them. This means: More energy savings Lower utility bills Leaving a smaller carbon footprint on the environment See energystar.gov for more information ConnectShare trade; MovieConnectShare Movie lets you watch videos play music or view photos from a USB connection without needing to use a PC or special equipment. Simply plug your USB device or drive directly into your Samsung TV's USB port and watch on the big screen with friends and family. HDMIGet superior picture and sound from your HD source. The High-Definition Multimedia Interface (HDMI) is a digital connection that can transmit HD video and audio over a single cable. Use it to optimize the image quality when you connect your TV to high-definition sources such as HD cable TV satellite receiver or Blu-ray player. [price_max] => 449.99 [name] => Samsung 32" Class 720p LED HDTV UN32EH4003 Black [id] => 26950189 [offer_count] => 21 [image_url_small] => http://www.onecall.com/media/catalog/product/S/a/Samsung-UN32EH4003.jpg [brand] => 31186 ) ) ) )


สมมติตัวแปรที่เก็บโครงสร้างอันนี้ชื่อ $xml
echo $xml['products']['product'][0]['@attributes']['name'];







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-04 19:35:08 By : cookiephp
 


 

No. 2

Guest


ได้แล้วครับผมขอบคุณพี่มากๆครับ ผมนั่งงมอยู่หลาย ชม เลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-04 19:54:55 By : Mr.S
 

 

No. 3



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-05 06:28:18 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ถามเกี่ยวกับการดึงข้อมูลจาก JSON Xml Array มาเป็นตัวแปรครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่