new to php, array question
Posted: Mon Aug 27, 2012 9:45 pm
Have put aside php in the last decade and now I've to pick that up again. I have a very simple question to ask.
I'm trying to move an array to another array by using a loop and a function. I wonder why when I do print_r the array, nothing gets print?
Below is my sample code.
I'm trying to move an array to another array by using a loop and a function. I wonder why when I do print_r the array, nothing gets print?
Below is my sample code.
Code: Select all
<?php
$All = array();
$ID_list = array("1", "2", "3");
foreach($ID_list as $ID) {
echo $ID . "<BR>";
subFunc($ID);
}
print_r($ALL);
function subFunc($ID) {
global $All;
$All[] = $ID;
}
?>