- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
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!
For the Googlers:
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.
why don’t you use urlencode() urldecode() :)
http://php.net/manual/en/function.urlencode.php
and then
Because when you explode(), PHP still treats the encoded version as a delimiter.