#php
List Assignment in PHP
$string = "Martha:18";
[$name, $age] = explode(":", $string);
echo $name; // Output: Martha
Require php version >= 7.1
(If you are using older version then use list() construct )
$string = "Martha:18";
list($name, $age) = explode(":", $string);
echo $name; // Output: Martha
List Assignment in PHP
$string = "Martha:18";
[$name, $age] = explode(":", $string);
echo $name; // Output: Martha
Require php version >= 7.1
(If you are using older version then use list() construct )
$string = "Martha:18";
list($name, $age) = explode(":", $string);
echo $name; // Output: Martha