I need to split a string into two using a delimiter character. All I have to do is use the explode () function ... I know.
But here's what I'm trying to do: I need to split the string using a separator, but if the separator is enclosed in quotation marks, it should be ignored.
Let's say my separator is a hyphen (-), and I need to break the following line:
"Big yellow house - near the lake
The first hyphen should be ignored because it is enclosed in quotation marks, so I would get two lines, such as:
1. "Big yellow house."
2. next to the lake
And he should also be able to detect hidden quotes.
For example: he does not like it because he is not here.
In this case, the hyphen is not enclosed in quotation marks, so the string must be separated.
Any thoughts?
user4697579
source share