SHARE
TWEET

Untitled

a guest Jul 17th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $arr = array();
  3. $str = "billing[firstname]";
  4. $val = "Joshua";
  5.  
  6. $parts = explode("[", $str);
  7. $arr_ref =& $arr;
  8. foreach ($parts as $part) {
  9.     $part = rtrim($part, "]");
  10.     print $part."\n";
  11.     $arr_ref =& $arr_ref[$part];
  12. }
  13. $arr_ref = $val;
  14. unset($arr_ref);
  15.  
  16. print_r($arr);
RAW Paste Data
Top