Code: Select all
$0 is the first element and $1 is the secondCode: Select all
array('foo', 'bar');Code: Select all
['foo'] is the first element and ['bar'] is the secondSimplified Recreation:
Code: Select all
private $_array;
private function _create($array)
{
$template = SomeClass::getTemplateString();
$this->_array = $array; // allows _parameterFormat access to the parameters; smelly
$ret = preg_replace_callback('/\$(\d+)/', array($this, '_parameterFormat'), $template);
$this->_array = null;
return $ret;
}
private function _parameterFormat($match)
{
return '[' . var_export($this->_array[$match[1]], true) . ']';
}