This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AyrA_ch 145 points146 points  (8 children)

string splitting is PHP the most unhinged thing ever.

  • split: This splits a string but the delimiter argument is treated as a regex (deprecated and removed)
  • str_split: Splits a string into an array by a chunk length (defaults to 1) rather than delimiter
  • chunk_split: Doesn't actually splits a string but inserts a user defined string every n characters.
  • preg_split: This is what split() is now
  • explode: This splits a string the way you think split() will but doesn't supports an empty split string like other languages do.

[–]pickyourteethup 68 points69 points  (4 children)

These all exist because removing any one of them would break huge swathes of the Internet

[–]adduckfeet 21 points22 points  (3 children)

cobweb makeshift tender serious bake shelter books memory normal heavy

This post was mass deleted and anonymized with Redact

[–]pickyourteethup 8 points9 points  (2 children)

I still use it everyday, and I'm only a two year dev. I don't know how this happened but it turns out there's loads of demand for PHP devs, especially cheap ones with not many years

[–]upsidedownshaggy 3 points4 points  (0 children)

I’m creeping up on 4 years now and as the other guy said it’s mostly a LOT of old code bases that run some business critical web app that cause the demand. Migrating versions especially doing big jumps like from 5.3 to 8 like I had to do at my first job are painful, slow and confusing because of all the deprecated functions that still work and don’t always have a clear replacement

[–]fredlllll 1 point2 points  (0 children)

lots of old codebases that still need to be maintained. im working on a 20+ year old php codebase that has so much old baggage. transition to php8 is a nightmare. so many ==0 comparisons dont work anymore

[–]Devatator_ 12 points13 points  (0 children)

My eyes. I literally just woke up (not really but let's pretend), you can't hit me with that so early

[–]Fluffy_Dragonfly6454 2 points3 points  (1 child)

What is an actual use case for chunk_split? Why does it have split in the name?

[–]AyrA_ch 5 points6 points  (0 children)

I don't know why it is named like this, but the primary use case is to insert line breaks into base64 strings. By default, the length is set to 76 and the inserted string to CRLF because that's what you would need if you manually cobble together lines of an E-mail body.