Jump to content

Variable Variables


sstangle73

Recommended Posts

i am trying to make a script that will make a varible 18 times here is what i have something is wrong

for($i=1; $i<=18; $i++){
${"player" . $i . "_number"} = ${$array[player .  $i . _number]};
}

it is something with the second half the

${$array[player .  $i . _number]};

i am trying to get it so it will do:

$player1_number = $array['player1_number'];
$player2_number = $array['player2_number'];
$player3_number = $array['player3_number'];
ect

 

Thanks!

 

EDIT

the error i am getting is

Notice: Use of undefined constant player - assumed 'player' in /homepages/27/d193007783/htdocs/maddogmania/application/roster.php on line 22

Notice: Use of undefined constant _number - assumed '_number' in /homepages/27/d193007783/htdocs/maddogmania/application/roster.php on line 22

Notice: Undefined variable: 07 in /homepages/27/d193007783/htdocs/maddogmania/application/roster.php on line 22

the third one where it has the variable 07, 07 is what the $player1_number should be set to if it worked right

 

Link to comment
https://forums.phpfreaks.com/topic/195252-variable-variables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.