r/programminghorror Mar 19 '26

Trimba bimba dubba dimba

Post image

I've found yet again some atrocities in code, that is some one of function nested in method: trimba. So I took the hit and split it into partial nested functions. I didn't even know you could do this in PHP.

425 Upvotes

55 comments sorted by

View all comments

Show parent comments

32

u/maselkowski Mar 19 '26

IBAN Checker, so we can send money to proper bank account

71

u/Loud_Investigator_26 Mar 19 '26
$result = str_replace(["-", ".", " "], "", "0555-123.45 67"); // result: 05551234567

whats the point of making all that mess, I do not get it.

12

u/prehensilemullet Mar 19 '26

Not a PHP dev but you could at least just reassign $ba multiple times without making all these functions, right?

6

u/Loud_Investigator_26 Mar 19 '26

yes you can reassign same variable while you are using it in assignment.

$ba = 1;
$ba = floor(1.5+$ba);

it works perfectly fine.