- print_r: documentation ( source)
- strtolower: documentation ( source)
<?php
$eggCount = 3;
for($i = 1; $i <= $eggCount; $i++) {
create("eggs", array($i => array("ID" => $i)));
}
function create($arrName, Array $arrKeys) {
$lName = "$".strtolower($arrName);
$$lName = array();
foreach($arrKeys as $key => $value) {
$$lName[$key] = $value;
}
for($i = 1; $i <= $GLOBALS['eggCount']; $i++) {
echo "Egg $i's ID: " . $eggs[$i]['ID'];
}
print_r($arrKeys);
}