In a php data strucutre,
PHP Code:
global $database;
$database = array(
array('something', 'something_else'),
array('anotherthing', 'yet_another'),
array('almost_there', 'last_thing'),
);
you would extract as follows,
PHP Code:
print $database[0][0]; // should print the first scalar from the first array
so if i went,
PHP Code:
global $i;
$i=0;
foreach ($database as $a)
{
if (!$a[$i]) {break;} else {print $a[$i].'<br>';
}
// in this $a becomes the array's inside the data structure ?
&
PHP Code:
global $i;
$i=0;
foreach ($database as $a)
{
if (!$database[$i][0]) {break;} else { print $database[$i][0].'<br>';}
$i++;
}
// this is now refrencing to the data structure that contains the arrays?
So this should print the whole data structure?
PHP Code:
foreach ($database as $a)
{
foreach ($a as $b)
{
if (!$b) {break;} else { print $b.'<br>';}
$i++;
}
}
What I am aiming to do is this.
Pass a varing amount of arrays to a include. The amount of scalars in the arrays is set and wont be more or less(some might be empty).
I can get them across with "global" easily enough. What is getting me is that foreach scalar in an array, I need to assign another value to another data structure.
would this work?
PHP Code:
global $ii;
$ii=0;
foreach ($database as $a)
{
foreach ($a as $b)
{
if (!$b) {break;} else { print $b.'<br>';}
array_push($data2[$i][$ii],$b);
$ii++;
}
$i++;
}
// cant figure this one out, example doesn't work ?
Basically for every scalar in each array in the 1st data structure, there needs to be one set in the 2nd data structure.
? ? ?
If anyone could try and explain how to do this I would greatly appreciate it.
I am sure I can return a favor.
Regards,
Edit:
Does it matter how I define the "$data2"?