Get strings from string

$string=“google=12 yahoo=publish bing=‘ok’ ask=0”;

how get the following from the $string?..
echo $google; output 12
echo $yahoo; output plublish
echo $bing; output ‘ok’
echo $ask; output 0

If it were a proper url string (eg “google=12&yahoo=publish&bing=‘ok’&ask=0”) I’d suggest parse_str

This should work fine for what you need to do

$string = "google=12 yahoo=publish bing=ok ask=0";
$splits = preg_split('/ /', $string);

foreach($splits as $split){
    echo preg_replace('/[a-zA-Z]+\\=/i', '', $split)."<br />";

Salathe beat me to it

You could use [font=monospace]sscanf()[/font] like:
(Multiple lines since Sitepoint’s code box is so narrow)

    "google=%d yahoo=%s bing=%s ask=%d",
    $google, $yahoo, $bing, $ask