PHP: How to turn a string that contains an array expression in an actual array?

后端 未结 4 617
广开言路
广开言路 2021-01-25 09:04

I have an array of user inputs ($atts) as key=>value pairs. Some of the values could be written as an array expression, such as:

\'setting\' => \'array(50,25)         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-25 09:40

    As suggested in the comments of your post, eval() will do what you're looking for. However it's not really practical to store arrays as strings in the first place. If you're looking to make data more portable, I'd recommend using json_encode() or even serialize()

提交回复
热议问题