Insert variable content into list()

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
us2rn4m2
New php-forum User
New php-forum User
Posts: 17
Joined: Thu Aug 09, 2012 1:28 pm

Re: Insert variable content into list()

Post by us2rn4m2 » Fri Sep 14, 2012 12:59 pm

Hi,

Code: Select all

$info  = array('brown', 'caffeine', 'hockey', 'football');
$sport = array();
                     //hokey   // football  
list($color, $power, $sport[0], $sport[1]) = $info;

echo $color . ' ' . $power . ' ' . $sport[0] . ' ' . $sport[1];

// Result: brown caffeine hockey football

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests