Firstly, I'm not new to programming, but I am new to PHP, so please forgive me if the answer to this is screamingly obvious...I've read through the manual, but haven't found anything. I've got a big string full of name/value pairs like so, where the delimiter is actually the null character "\x00"
$data = "variant.standard.password.0.timelimit.25.options..hasoverrides.0.dedicated.1.linux.0";
Now, I need to break this up into an associative array like so:
$assoc = array(
'variant' => 'standard',
'password' => '0',
'timelimit' => '25',
'options' => '',
'hasoverrides' => '0',
'dedicated' => '1',
'linux' => '0',
);
I could do this by exploding the entire string into a normal array, then looping through and assigning every two values to a different array, one as the key and the other as a value, but I can't help but think there has to be a better way that doesn't require duplicating the entire structure.
Normally I wouldn't sweat it, but the structure could potentially become MUCH larger than the 7 pairs in this example, causing a massive performance hit if we duplicate the whole thing every time. I'd appreciate any advice anyone can provide...thanks!