php - Creating array from string -


I need to create an array like this:

  array ('firstkey' = & Array ('secondkin' = & gt; array ('nky' => gt; ...))  

From:

  Firstkey.secondkey Nkey (...)  

$ yourstring = 'firstkey.secondkey .nkey '; // Split the string into pieces $ pieces = explosion ('.', $ YourString); $ Result = array (); $ $ Is a reference to the current array in which new elements $ $ current and $ should be added; Add an empty array to the foreign currency ($ $ as the $ key) {// current array $ existing [$ key] = array (); // Get new array $ current = and $ current [$]; } // $ in the result you want to include the array

Comments