0
 $shop = array( array("aaa", 1.25 , 15),
                array("bbb", 0.75 , 25),
                array("ccc", 1.15 , 7) 
              );    

 for ($row = 0; $row < 3; $row++) {
     for ($col = 0; $col < 3; $col++) {
         echo $shop[$row][$col] . "/";
     }
 }

Result:

aa / 1.25 / 15 / bbb / 0.75 / 25 / ccc / 1.15 / 7 /


How can I add a new array in this array?

For example:

array("ddd", 1.30 , 9)

AlexV
  • 22,658
  • 18
  • 85
  • 122
M1NT
  • 386
  • 1
  • 4
  • 13

2 Answers2

2

You can do this by doing $shop[] = array("ddd", 1.30 , 9);

Tim Wachter
  • 732
  • 5
  • 22
0

Most languages have a method built in to push on to the array. PHP specifically can do it thusly:

array_push($shop, array("ddd", 1.30 , 9));
captbrogers
  • 475
  • 5
  • 15