I have the following passed as an array to my Twig template:
Array
(
[0] => Array
(
[url] => http://somedomain.com/somepage1
[0] => http://somedomain.com/somepage1
[count] => 27
[1] => 27
)
[1] => Array
(
[url] => http://somedomain.com/somepage2
[0] => http://somedomain.com/somepage2
[count] => 7
[1] => 7
)
)
Now I need to do something like this:
foreach ( $response as $key => $element ) {
if ( global.request.uri == $response->url ) {
break;
}
}
I know how to imitate break
in Twig (from this answer), but I don't know how to imitate as $key => $element
. So how do I stop my loop when it finds an object containing the string that meets my condition? Moreover, how do I then output the value of count
in that object?
Unlike this question, my arrays contain multiple keys each with some values assigned to each key, and not just "alpha/bravo" strings. So I don't understand how to apply the answer to that question to my case.