What's the easiest way to get part of a string enclosed in delimiters?

For example there is a line /foo/{bar} need to get bar or /foo/{bar}/{baz} to bar, and baz, respectively, and is it possible to implement this without regular expressions?
July 12th 19 at 16:40
2 answers
July 12th 19 at 16:42
$url = "/foo/{bar}/{baz}";
$data = array_filter(explode("/", $url), function ($value) { return strpos($value, "{") === 0; });
var_dump($data); // [2] => "{bar}", [3] => "{baz}"
July 12th 19 at 16:44
of course, without regexps and done

print(o[1]) #{bar}
print(o[2]) #{baz}
So the split is not enough that Deprecated so also breaks with the help of the regular season - Toy.Bednar commented on July 12th 19 at 16:47
I don't believe about the regular season, although I don't know how in PHP, well, write a variant with substr/strchr or whatever - alisa_Morar44 commented on July 12th 19 at 16:50

Find more questions by tags PHP