Jake Wilson
Jake Wilson

Reputation: 91193

Symfony get current URI slugs as array?

In Symfony, how do you get the current URI slugs as an array?

www.mysite.com/this/that/test/hello/world/7?whatever=true

What command is used to get the following array:

[0] => 'this',
[1] => 'that',
[2] => 'test',
[3] => 'hello',
[4] => 'world',
[5] => '7'

Upvotes: 0

Views: 762

Answers (2)

Louis Huppenbauer
Louis Huppenbauer

Reputation: 3714

Try the following:

explode('/', $request->getPathInfo());

(I don't actually know where you'll get your request object from, so you'll may have to rename the variable)

Upvotes: 2

Greg Motyl
Greg Motyl

Reputation: 2545

This should work:

 explode('/',$this->getContext()->getRouting()->getCurrentInternalUri());

Upvotes: 0

Related Questions