3
05/11/2024 5:49 am
Topic starter
I want to use while with array - have 3 arrays (maybe some products) with Php. Thanks
1 Answer
2
05/11/2024 5:50 am
Try this code:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>While and Array in Php</title> </head> <body> <?php $goods = [ [ 'title' => 'Nokia', 'price' => '$100', 'description' => 'Info' ], [ 'title' => 'Surface Pro 6', 'price' => '£600', 'description' => 'Info' ], [ 'title' => 'Sony', 'price' => '£300', 'description' => 'Info' ] ]; $i = 0; while ( $i < 3 ) { echo $goods[ $i ]['title'] . ' - ' . $goods[ $i ]['price']; echo '<br>'; $i++; } ?> </body> </html>