Is there any way, to make something like:
$elements_string = array()
foreach ($something as $element => $value ) {
$elements_string[$element] = $value;
...
}
And save $elements_string into a db row?
Maybe you guys prefer some other way?
I wan’t to read it from the database so I can easly parse the string.
Earlier I was using something similar to:
$elements_string = $element . ":" . $value;
And I was trying to use explode on that, but that makes no sense because I need to have $element and $value in one loop for one element.
Normally you would store each element and value in a different row.
If you must store them in one row (and be sure you really have to do that), then use
serialize()http://www.php.net/serialize to turn an array into a string you can store.You can do other things to like: value:element;value:element – then you first split by semicolon, then by colon.