How can I convert string to an array?
Input:
$string = "12&Shoes&28&Jewelry&30&Watch&96&Beauty&98&Kids&Baby";
Desired output:
array{
[12] => 'Shoes',
[28] => 'Jewelry',
[30] => 'Watch',
[96] => 'Beauty',
[98] => 'Kids&Baby'
}
Can anyone suggest how I can concisely convert it using a PHP function like preg_match()
, preg_match_all()
, etc.?