Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Like @k0pernikus said, why do you not use a foreach. Commenting because I'm curious if there is a reason to not use foreach.
-
@aronmik there is one... Let's say you have two arrays you know they'll be the same length for each doesn't allow you to do two things at once ...
I.e
For (int I = 0; I < 5;I++) {
Array0[I];
Array1[I];
}
You can technically do it In foreach but then you'll be creating your own for loop -
ruuds9638y@FitzSuperUser thats still possible if those arrays are not key/value arrays. Just use foreach($list as $index => $item) and use index to do the things you want to do to the other array
-
@ruuds96 That is very logical, but some people (including me) just prefer C style stuff.
-
Be aware that putting the length of the array (or count for php) in a variable slightly improves performance.
-
samritbk3628y@zmzmuazzam98 I get your hustle bro. I wprk with both the languages too 😅😅😅
-
If you're "searching" for something in an array, maybe you don't even have to loop. array_search( ), anyone?
Related Rants
When searching through an array,because I also program using Java,i always end up putting for(x=0;x<array.length ;x++){}
Now in php I have to deal with this
undefined
php
wk30