Q:

Taking values from string to array

Is it possible take a value from a STRING like:
$string = ' * some parameter: A+ * Nextparameter: 0,671 kWh/24h * 
        Some another parameter value: 245 kWh/year * Last parm: 59 kg'; 

Now i know what parameters i need and a have a list:
My parameters what I'm finding (always will be the same):
$parm1 = "* some parameter:";
$parm2 = "* Nextparameter:";
$parm3 = "* Some another parameter value:";
$parm4 = "* Last parm:";

How can I get this result:
$parm1result = "A+";
.. etc ...

Or, the best way:
$result = array(
    "some parameter" => "A+",
    "Nextparameter" => "0.671", 
    ... etc ...
);

Thank you ...

A:

Sorry, last post got screwed up. 
You need to split twice and apply some trimming:
<? php
$string = ' * some parameter: A+ * Nextparameter: 0,671 kWh/24h *
    Some another parameter value: 245 kWh/year * Last parm: 59 kg';

// remove beginning and ending stars and whitespace so we don't have empty values
$string = trim($string, ' *');

// get parameters
$arr = explode('*', $string);

// trim a little more
$arr = array_map(trim, $arr);

// add stuff to array
$result = array();
foreach ($arr as $param) {
  // nicer way of representing an array of 2 values
  list($key, $value) = explode(':', $param);
  $result[trim($key)] = trim($value);
}
var_export($result);
? >

