It's weird how simple things like these I cannot find about php on the internet. Without further ado, how do I find an element inside an array that already has a string index, with a position?
For example:
$array = ["apple"=>"red","raspberry"=>"blue","green","yellow"] // As you can see this is a mixed array
for($i=0;$i<=count($array);$i++){
var_dump(getelementfrompos($array,$i)) // pseudocode
}
// output
array(2) => {
[key] => string(5) "apple";
[value] => string(3) "red"
}
array(2) => {
[key] => string(9) "raspberry";
[value] => string(4) "blue"
}
array(2) => {
[key] => integer(2);
[value] => string(5) "green"
}
array(2) => {
[key] => integer(3);
[value] => string(6) "yellow"
}
DUMBED DOWN VERSION:
$array = ["apple"=>"red"]
getkeyfrompos($array,0) // returns -> "apple"
How do I find an element inside an array that already has a string index, with a position, as if it was an element with a numerical index instead?