I want to do something like this
$cars = array('1', '2', '3', '4', '5', '6');
$cars = array('7', '8', '9', '10', '11', '12');
$cars = array('13', '14', '15', '16', '17', '18');
foreach ($cars as $car){
echo $car[0].'<br />';
echo $car[1].'<br />';
echo $car[2].'<br />';
echo $car[3].'<br />';
echo $car[4].'<br />';
echo $car[5].'<br />';
echo '----------------<br />';
}
to get a result like this
1
2
3
4
5
6
----------------
7
8
9
10
11
12
----------------
13
14
15
16
17
18
I was hoping this code would work but I get errors like :Notice: Uninitialized string offset: 2 in C:\xampp\htdocs\....php on line 9
I have tried a lot of thing like $cars = array(array('1', '2', '3', '4', '5', '6')); but none of them worked for me, so please if anyone could help me with this one, I am new to php and I hope to learn more from you.
$cars[] = array(...in your first 3 lines. (add[]after$cars). right now you are overwriting$carseach time.