In PHP we can split a string and transform it into array
.
Example:
$url = 'pagina/id/1';
explode('/', $url);
Result:
['page', 'id', '1']
However, if this url had a slash before and after, it would return some empty values.
$url = '/pagina/id/1/';
explode('/', $url);
['', 'page', 'id', '1', '']
How could you make sure these empty values are not returned (without having to array_filter
)?