In my database, some field parameters are serialized and saved. When I do this:
print_r(unserialized($r['settings']));
I will get this:
Array (
[prefix] =>
[suffix] =>
[min] =>
[max] =>
[allowed_values] => 1|Common 2|Rare 3|Almost Extinct
)
I am trying to create an array based on values for allowed_values, such as:
Array (
[1] => Common
[2] => Rare
[3] => Almost Extinct
)
The problem is that when I use explode ("|", $ r ['allowed_values']), I get:
Array(
[0] => 1
[1] => Common 2
[2] => Rare 3
[3] => Almost Extinct
)
That makes sense, but obviously not what I was hoping for ... So, I'm just wondering if there is an easy way to do what I'm trying here? I thought about using the gap several times, once for spaces and once for pipes, but this will not work because of the space in "Almost Extinct" ...
source
share