Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End explode() and escaped characters?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28896
    jlizarraga
    Member

    Hi all,

    So I have some URLs that look like this:

    /details/Type+Year+Make+Model+Trim+VIN

    I then explode() everything after "/details/" using "+" as the delimiter.

    Problem is, today I’m encountering some data where the "Trim" part has a "+" in it. Here’s the string in question:

    New+2010+Kia+Soul+2.0L I4 ++KNDJT2A2XA7105256

    To try and solve this, I escaped the + like so:

    New+2010+Kia+Soul+2.0L I4 %2B+KNDJT2A2XA7105256

    When I explode() this string, PHP recognizes the "%2B" as a "+" and treats it as a delimiter.

    How can I escape the "+" so that explode() won’t treat it as a delimiter?

    Thanks!

    #75039
    jlizarraga
    Member
    #75040
    jlizarraga
    Member
    "TT_Mark" wrote:
    Don’t think you can?

    Any reason you cannot just use another delimeter?

    These URLs are for SEO, so the delimiter options were limited to space/%20, – (hyphen/dash/minus/etc), . (period), ant + (plus sign). AFAIK, these are your options for characters that search engines will treat as spaces. Prior to this incident, "+" was the ONLY one of these delimiters that didn’t show up in our data.

    #75047
    Rob MacKay
    Participant
    #75080
    jlizarraga
    Member

    Because when you explode(), PHP still treats the encoded version as a delimiter.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.