I want to run a for loop through an array and create anchor elements for each element in the array, where the key is the text part and the value is the URL.
How can I do this please?
Thank you.
I want to run a for loop through an array and create anchor elements for each element in the array, where the key is the text part and the value is the URL.
How can I do this please?
Thank you.
For some specific purposes you may want to know the current key of your array without going on a loop. In this case you could do the following:
The above example will show the Key and the Value of the first record of your Array.
The following functions are not very well known but can be pretty useful in very specific cases:
This should do it
Edit: As per Capsule's comment - changed to single quotes.
Like this:
In a template context, it would be:
You shouldn't write your HTML code inside your PHP code, hence avoid echoing a bunch of HTML.
This is not filtering anything, I hope your array is clean ;-)