3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = '0x 1121 0031'; $data = substr($data, 2); //remove the 0x prefix from the string $data = str_replace(' ', '', $data); //remove the spaces from the string //$data is now '11210031' echo 'the product number is ' . $data[0] . "\n"; if ($data[1] == 1) { echo "this is a new product\n"; } else if ($data[1] == 2) { echo "this is a used product\n"; }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
the product number is 1 this is a new product

preferences:
118.38 ms | 402 KiB | 150 Q