- array_chunk: documentation ( source)
- var_export: documentation ( source)
- preg_split: documentation ( source)
<?php
$text="key1=value 1 key2=value 2 key3=val 3";
var_export(array_chunk(preg_split('~=| (?=\w+=)~', $text), 2));
echo "\n---\n";
var_export(array_chunk(preg_split('~ ?(\w+)=~', $text, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE), 2));