I'm trying to create a pattern matching scenario where you match a url such as
'/events/display/9382817/featured/' => 'events'
to the event method and parameter match
Array (
['method'] => 'display',
['parameter'] => Array([0] => 9382817, [1]=> 'featured');
I have this partial expression
^/(?P<method>.*?)/(?P<parameter>.*?)
But it doesn't quite work. I am not good at regex
I believe with this pattern we can then alter line
if (class_exists($class)) {
$obj = new $class;
if (method_exists($obj, $method)) {
$obj->$method($matches);
} else {
to something like
if (class_exists($class)) {
$obj = new $class;
$method = $matches['method'] || $method;
$params = $matches['parameter'] || null
if (method_exists($obj, $method)) {
$obj->$method($params);
} else {
We can probably link url to class method logic
Please help/ advise