I'm trying to convert a flat file txt database over to mysql, but I'm unable to convert the variables over to the a valve.
On another projects I used this code in the past:
$this->url = preg_replace("/\{(\w+)\}/e", '$$1', $url);
And now I'm using along with an array to convert the variables to valves:
$url = preg_replace_callback('/\{(\w+)\}/', function($match) use ($values) {if isset($values[$match[1]])) {return $values[$match[1]];} else {return $match[0]; }},$url);
The only issue with doing this is, there will be a lot of items converted into array and cause of errors if not there.
Can someone explain a way to do this better and with less user error?
Thanks in advance.