I got a string var named: $taxonomy_str
For example, echo $taxonomy_str will display:
array('relation' => 'AND',
array('taxonomy' => category,
'field' => 'id',
'terms' => array( 41, 42 ),
'operator' => 'IN'),
array('taxonomy' => geography,
'field' => 'id',
'terms' => array( 20, 29 ),
'operator' => 'IN')
)
I need a way to convert this string with an array statement into a real array, how can I achieve this using PHP?
Thanks.
eval(), but 999 times out of 1000 there is a safer and more elegant alternative to accomplish what you want before you have to resort toeval().serialize()andunserialize()OR use combinations ofjson_encode()andjson_decode()