I have an array that looks like this.
'keyvals' =>
array
'key1' => 'value1'
'key2' => 'value2'
'key3' => 'value3'
Is there a cool way to flatten it to a string like 'value1 value2 value3'
? I also have access to PHP 5.3 if there's something new there.
$someArray = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
);
implode(' ', $someArray); // => "value1 value2 value3"
See implode
:
$flat = implode(' ', $array['keyvals']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With