I use PHP and have an array that looks like this:
Array
(
[34] => Array
(
[slug] => my_slug
[title] => my_title
)
[33] => Array
(
[slug] => my_slug2
[title] => my_title2
)
)
I also need to loop out the sets, key 34 with values and key 33 with values. I could loop them out with a foreach but in my case I can't use a foreach loop.
Problem - Loop by index?
Because I can't use a foreach loop in my case I need to come up with something where I can loop them by index.
My own thoughts
if I could get the array keys by index it would be fine. Is it possible, how?
<?php print_r( $my_array[index][0] ); ?>
<?php print_r( $my_array[index][1] ); ?>
Reasons
The reason why I can't use a foreach is that I am depending on a counter. If the counter says 3 it wants to get the fourth key (arrays starts with 0).
Example 1
$counter = 1;
Then it should return the contents of [33] because it's on the index 1.
Example 2
$counter = 0;
Then it should return the contents of [34] because it's on the index 0.
$my_array[$counter]['slug']?array_keysphp function.for ($i = 0, $count = count$(my_array); $i < $count; $i++ { // do something with $my_array[$i] }