I am making a parser for my SlashCategory, which requires me to split (or tokenize) each string based on the /
character. I am using PHP's explode()
function, which works well. For example, it takes the following:
Book/Title/Lord Of The Flies/Author/William Golding
And creates an array with:
[0] Book
[1] Title
[2] Lord Of The Flies
[3] Author
[4] William Golding
However, I have a problem. I do not want explode()
to break up the string if the forward slash is preceded by a backslash. For example:
Url/Google/http:\/\/www.google.com
I want to have an array containing:
[0] Url
[1] Google
[2] http://www.google.com
Not:
[0] Url
[1] Google
[2] http:
[3]
[4] www.google.com
How can I do this?