3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getParts() { return json_decode(<<<EOF [ { "name": "lorem ipsum", "category": "hi", "quantity": "2", "price": "55", "id": 1756378, "shelf": "30", "slot": "173" }, { "name": "foo bar", "category": "there", "quantity": "2", "price": "90", "id": 1181335, "shelf": "", "slot": "" } ] EOF , true); } function getPartByName($name) { $matches = []; $parts = getParts(); foreach ($parts as $part) { if (str_starts_with($part['name'], $name)) { $matches[] = $part; } } return $matches; } print_r(getPartByName('lorem'));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Array ( [0] => Array ( [name] => lorem ipsum [category] => hi [quantity] => 2 [price] => 55 [id] => 1756378 [shelf] => 30 [slot] => 173 ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
113.56 ms | 407 KiB | 5 Q