I have a pretty basic question:
What is this statement actually doing (specifically the =>$p
)?
foreach ($email->parts as $partno=>$p) {
I understand the the basics but the =>$p
is not clear
I have a pretty basic question:
What is this statement actually doing (specifically the =>$p
)?
foreach ($email->parts as $partno=>$p) {
I understand the the basics but the =>$p
is not clear
In a foreach
loop you can ask for both the key and value to be returned
$array = array('cat' => 'Tom', 'mouse' => 'Jerry');
foreach($array as $animal => $name) {
echo $name . ' is a ' . $animal . '<br>';
}
So the loop will output
Tom is a cat
Jerry is a mouse