So much wrong there. Not sure where to start.
You should be getting a bunch or warnings with that code even if no errors show up.
Instead of going through what is wrong, I'll just show you the correct way of doing it.
Code:
foreach($stpw as $row){
$inv = array('db'=>'w', 'id'=>$row['idinvoice'], 'rstop'=>$row['rstop']);
[indent][/indent]...
}
That should correctly create your array. The "=>" is an assignment operator. You only use it when you assign a value. When outputting it should never be used.
You can verify your array by using the print_r() method. The echo method cannot directly print arrays, so only prints out "Array" as a way of telling you what you are trying to print is an array.
You can surround the output of print_r with <pre> html tags so it maintains the pre-formatted text from the array so its easier to read.
Code:
echo "<pre>";
print_r($inv);
echo "</pre>";
If you want to then select a particular item in the array, you can do so via the index.
For instance if I wanted to output the 'id' part of that array:
This should output whatever $row['idinvoice'] had as a value.
If I do
It would output the letter "w" as that what you assigned it to.
The main issue, you had, was your array was not being constructed correctly, so it could not be accessed.
You were also creating an array of arrays:
Code:
$inv[b][][/b] = array(...);
This makes $inv an array, and assigns another array to the the first available index in $inv.
To then access that array, you first need to go through the parent array.
$inv[0] would select the first index, and then you can select the inner item you want.
Code:
echo $inv[0]['id'];
//or
echo $inv['0']['rstop'];
//etc...
----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.
Web & Tech