This is my array :
$arr = [
// fisrt part
[
'1' => 'one',
'2' => 'two',
'3' => 'three',
'completedLanguages' => [
0 => 'cpp',
1 => 'javascript',
],
],
// second part
[
'4' => 'four',
'5' => 'five',
'6' => 'six',
'completedLanguages' => [
0 => 'php',
1 => 'python',
2 => 'go',
],
],
// third part
[
'7' => 'seven',
'8' => 'eight',
'9' => 'nine',
'completedLanguages' => [
0 => 'csharp',
1 => 'vb',
2 => 'rust',
3 => 'scala',
],
],
];
In each of these three parts there is an index called completedLanguages
.
In completedLanguages
index, there may be a number of variable values each time.
I want to go into the parts one by one and print all the values in their completedLanguages
index. And finally, if all the values printed, I go to the next part until print the completedLanguages
index values of all the parts.
For a better understanding, look at the following loop:
for ($i = 0; $i <= count($arr[0]['completedLanguages']) - 1; $i++) {
echo $arr[0]['completedLanguages'][$i] . '<br>';
}
The number 0 in $arr[0]['completedLanguages']
can vary depending on the number of parts in this array. For example in this array we have three parts!