You often want to take out arrays one by one with a for statement and assign them to variables. The subtle differences between different languages can damage your brain. Here we will cover Python, JavaScript, and PHP.
With Python
for(Variable in array)
#Processing you want to repeat
It's in. And Python is indented without {}.
And everyone loves JS
//When in an array
for(Variable of array){
//Processing you want to repeat
}
It's of. By the way, if it is an object, in is used.
And with PHP
foreach($Array as$variable){
//Processing you want to repeat
}
Use foreach instead of for statement and as.
It seems to be confused ………
Recommended Posts