Pantip.com Pantip-TechExchange | Pantip-Cafe | PantipMarket.com | Chat | PanTown.com | BlogGang.com| Torakhong.org| GameRoom
 




เรื่องการทำให้ตัวแปร 2 ตัวเป็นตัวแปรตัวเดียวกัน (php)

ตัวอย่างนะคับ สมมุติว่าผมมีตัวแปรอาเรย์ ดังนี้
$c1[]=0;
$c1[]=1;
$c2[]=3;
$c2[]=4;

จากตัวอย่างนะคับ ผมต้องการที่จะวนลูปมาดูค่าของตัวแปร c1 และ c2 โดยการที่จะให้วนลูปดังนี้

for($i=1;$i<=2;$i++){
foreach($c$i as $value){
echo $value."<br>";
}
}
คือผมอยากจะแสดงค่าของตัวแปร c1 กับ c2 ออกมาพร้อม ๆ กัน โดยลักษณะดังตัวอย่างแต่มันทำไม่ได้ เพราะว่ามัน error ตรง $c$i ใน foreach ซึ่งผมต้องการที่จะเชื่อมตัวแปร $c กับ $i ให้เป็นตัวว่า $c1 และ $c2 ตามลำดับ ไม่ทราบว่าผมจะมีวิธีทำอย่างไรคับ


จากคุณ : bnet -[ 13 ก.ย. 50 - 01:23:56 A:124.120.114.245 X: ]




ข้อความหรือรูปภาพที่ปรากฏในกระทู้ที่ท่านเห็นอยู่นี้ เกิดจากการตั้งกระทู้และถูกส่งขึ้นกระดานข่าวโดยอัตโนมัติจากบุคคลทั่วไป ซึ่ง PANTIP.COM มิได้มีส่วนร่วมรู้เห็น ตรวจสอบ หรือพิสูจน์ข้อเท็จจริงใดๆ ทั้งสิ้น หากท่านพบเห็นข้อความ หรือรูปภาพในกระทู้ที่ไม่เหมาะสม กรุณาแจ้งทีมงานทราบ เพื่อดำเนินการต่อไป
Considering the real-time nature of this webboard, it is impossible for us to review all messages/post. Please remember that we do not actively monitor the contents of and are not responsible for any messages posted. Anyone who feels that a posted message is inappropriate, Please encouraged to contact us immediately by email at kratoo@pantip.com , and We will remove objectionable messages within a reasonable time frame.



Pantip-Cafe | Pantip-TechExchange | PantipMarket.com | PanTown.com | BlogGang.com