forum

Home / DeveloperSection / Forums / How can I convert this string to array?

How can I convert this string to array?

Anonymous User313505-Oct-2013

I am stucked with converting the string of specific format to array. Spliting the string using explodedoesn't seems to be the right approach and i am not so good with regular expressions. So my question is how can i convert the following string to array?

Current format of the string


maxWidth: 800, 
openEffect: elastic,
closeEffect: elastic,
helpers : {
       title : {
             type: outside
           },
       thumbs : {
              width : 50,
              height : 50
            }
      }


Desired Array

array( 
  'maxWidth' => 800,
  'openEffect' => 'elastic',
  'closeEffect' => 'elastic',
  'helpers' => array(
               'title' => array('type' => 'outside'),
               'thumbs' => array('width' => 50, 'height' => 50)
             )
)


Any help would be greatly appreciated.


Updated on 05-Oct-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By