<?php $leadinString = '$value'; // or '$test' or 'foobar' or whatever $str = '{$value.level-1.level-2.level-3 ... level-n}'; echo str_replace(array("$leadinString.", '}', '.'), array($leadinString . "['", "']", "']['"), $str);
Standard input is empty