- preg_replace_callback: documentation ( source)
- print_r: documentation ( source)
<?php
$str = '[locations][0][name]';
function angularModel ($formName, $inputName)
{
$retVal = "formData ['" . $formName . "']";
$retVal .= preg_replace_callback ('/\[\w+\]/', function ($matches) {
print_r ($matches);
}, $inputName);
return $retVal;
}
angularModel ('relation', $str);