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
-
If I had the dude who wrote these lines in front of me I wouldn't know where to start to yell at him
-
Only the first lines of code makes me yell.
"$out[2] = $outNew;
$matchesArray = $out[2];"
- What if we make PHP do more work? -
@NotFound maybe the dude didn't know about the usleep() function...
Or he charged for lines of code written. -
@GodHatesMe precisely because of that, I was staring into the abyss for a couple of minutes. Code had to make sense for me, and this did not, until I realized that it's completely redundant
-
Yes... And No...
PHP, especially array handling, is due to typing, one hell of a bitch.
If I'm not mistaken, depending on the version and error configuration, this code can do very different things.
If the matchesArray is an array with holes or associative, this way of putting together the values assures that the final variable contains a numerical indexed array without holes - if the variable in the array at index $i does not exist, it's value is null now...
This is a a very cumbersome and edgy corner case, but dependent on what happens with the result array, IT can be very important.
Not redundant but very bad written.
array_fill / array_value / range, depending on situation, are netter suited. -
@IntrusionCM it was after a regex match. That's what I remember. The screenshot is several years old now, I don't work on that code base any longer. But the initial data is a sequential array, with no special stuff.
-
C0D4669017yRedundancies everywhere 😞
This could so easily be 2 lines, 3 if you want to speed up the for loop a bit depending on the size of the array.
Some people make me cry ðŸ˜
Related Rants
If I disregard all Wordpress code examples, this must have been one of the best examples of bad code. It took minutes to understand what it does.
undefined
wk72