3v4l.org

run code in 300+ PHP versions simultaneously
<?php $product = []; for ($k = 0; $k <= 100; $k++) { $options = []; for ($j = 0; $j <= 10; $j++) { $optionItems = []; for ($i = 0; $i <= 100; $i++) { $optionItems[] = array( 'title' => 'OptionItem' . $i, 'description' => 'OptionItem ' . $i . ' Description', 'price' => random_int(1000, 10000) ); } $options[] = array( 'title' => 'Option' . $j, 'description' => 'Option ' . $j . ' Description', 'price' => random_int(1000, 10000), 'items' => $optionItems ); } $product[] = array( 'title' => 'Product' . $k, 'description' => 'Product ' . $k . ' Description', 'price' => random_int(1000, 10000), 'currency' => 'USD', 'category' => 'Category' . $k, 'brand' => 'Brand' . $k, 'options' => $options ); }
Output for 8.2.18 - 8.2.26, 8.3.5 - 8.3.14, 8.4.1
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Out of memory (allocated 31457280 bytes) (tried to allocate 20480 bytes) in /in/h08dj on line 9 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.

preferences:
43 ms | 407 KiB | 5 Q