3v4l.org

run code in 300+ PHP versions simultaneously
<?php # read config file data from the file using file_get_contents $string = '{ "mysql": { "host": "locahost", "port": 3306, "database": "test", "username": "root", "password": "" } }'; $cfg = json_decode($string,1); # decode the result as an array $host = $cfg["mysql"]["host"]; $port = $cfg["mysql"]["port"]; $database = $cfg["mysql"]["database"]; $username = $cfg["mysql"]["username"]; $password = $cfg["mysql"]["password"]; echo "host = $host, port = $port, database=$database, username=$username, password=$password"; ?>

preferences:
61.47 ms | 402 KiB | 5 Q