String replace how to

I have some values stored in a database, sometimes it is only one sometimes several separated by a mysql linebrake, like

instance where I only have a value

name=value

instance where I have more than 1 value

name1=valuex
name2=valuey
etc

I am trying to parse this, in the first case I am able to achieve it like this

(bellow the value inside the mysql db)

Style=somestyle

$style_name = str_replace(“Style=”, “”, $params_to_string);

in the case above I am getting
$style_name = somestyle;

then I can use the string somestyle and do what I need to, but now I got to the place where there are more of this values in the db all have a different name and are separated by a linebrake, can someone give a sample on how to parse the one bellow?

style=somestyle
language=somelanguage

Would you be better off cleaning up the data in the database?

[google]mysql REPLACE[/google] function.

What is the result you need from the parsing?

this is not an option for me, I am making a joomla template and joomla stores the parameters that way so I can´t just randomly modify the database, that will probably mess up the site, thank you anyway

I only need the part after the =, so in the sample style=style1 I would need the string style1 in the sample language=en I would need the string en, the above example is stored in mysql like this

style=style1
language=en

It looks just like that, well the style and language can be anything, I am making those names so they can be anything I want, also the part after the = sign, but they are stored in that exact same way, so if I wanted to have a variation of styles like style1, style2 etc then the style field can be either style=style1 or style=style2 and I need that part after the = sign so I can use it in the code, I am able to achieve it when there is only 1 parameter, but if there is more than 1 I have no idea how to do it.

If there is more than 1 you have no idea how to do it, but why? is this too difficult?

For me yes, I am learning and have not been able to figure how to do it, that is why I asked


$values = explode("\
", $params_to_string);
foreach ($values as $key => $value) {
  list($paramname, $paramvalue) = explode('=', $value);
  echo $paramname . ' = ' . $paramvalue;
}

Thank you I will try that!

That worked thanks however I will not use it, as I was trying to figure it out, I found a document explaining how this can be done in joomla which is where I am trying to use it and it has a way of getting this easy, here is what I found in case anyone comes looking for the same

$params->get(‘param_name’);