PHP find first of occurrence of string
- by mike
I have a string of data like below and I've been struggling trying to figure out how to split it up so that I can use it efficiently.
"United States FirstName: Mike LastName: Wolf City: Chicago"
I need to split up the string in to substrings and the list may not always be in the same order.
For example it could vary like below:
"United States City: Chicago FirstName: Mike LastName: Wolf"
"United States FirstName: City: Chicago Mike LastName: Wolf"
I need to find which parameter comes first after 'United States'. It could be 'City:', 'FirstName:' or 'LastName:'. And, I also need to know the start position of the first parameter.
Thanks in advance!