3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $contentLines = file('path/to/content.txt'); $contentLines = [ 'Weight 229.6104534866 g', 'Energy 374.79170898476 kcal', 'Total lipid (fat) 22.163422468932 g', 'Carbohydrate, by difference 13.641848209743 g', 'Sugars, total 4.3691034101428 g', 'Protein 29.256342349938 g', 'Sodium, Na 468.99386390008 mg', ]; var_export( array_map( fn($line) => sscanf( $line, '%[^0-9] %f %s', ), $contentLines ) );
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.29, 8.4.1 - 8.4.14, 8.4.16 - 8.4.17, 8.5.0 - 8.5.2
array ( 0 => array ( 0 => 'Weight ', 1 => 229.6104534866, 2 => 'g', ), 1 => array ( 0 => 'Energy ', 1 => 374.79170898476, 2 => 'kcal', ), 2 => array ( 0 => 'Total lipid (fat) ', 1 => 22.163422468932, 2 => 'g', ), 3 => array ( 0 => 'Carbohydrate, by difference ', 1 => 13.641848209743, 2 => 'g', ), 4 => array ( 0 => 'Sugars, total ', 1 => 4.3691034101428, 2 => 'g', ), 5 => array ( 0 => 'Protein ', 1 => 29.256342349938, 2 => 'g', ), 6 => array ( 0 => 'Sodium, Na ', 1 => 468.99386390008, 2 => 'mg', ), )
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:
191.48 ms | 408 KiB | 5 Q