- var_dump: documentation ( source)
- explode: documentation ( source)
<?php
$input = '1,Home,3,Services,6,Service 1,7,Service 2,2,Products';
$keysAndValues = explode(',', $input);
$result = [];
$count = count($keysAndValues);
for ($i = 0; $i < $count; $i+=2) {
$key = $keysAndValues[$i];
$value = $keysAndValues[$i+1];
$result[$key] = $value;
}
var_dump($result);