3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @author ciid */ class Variadic { public array $names = []; public function __construct( string ...$names, // ...[string $name => mixed $value], ) { $this->names = $names; } } $var = new Variadic('wan', 'chew', 'tree'); var_dump($var); $json = '{"names":["wan", "chew", "tree"]}'; $obj = json_decode($json); var_dump($obj);

preferences:
29.46 ms | 411 KiB | 5 Q