Jump to content

[SOLVED] variable variable array


aniesh82

Recommended Posts

Hi,

 

I used the variable -variable concept to create dynamic array names.. but it is not working like I expected..

 


<?php

#dynamicarray.php

for($i=1;$i<=5;$i++)
{
$name	=	'b'.$i;

$$name[]	=	10;
}

print_r($b1);

/**

Expected Output is:

$b1[]		=	10;
$b1[]		=	10;

$b2[]		=	10;
$b2[]		=	10;

*/

?>

Link to comment
https://forums.phpfreaks.com/topic/118508-solved-variable-variable-array/
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.