I have the below code where I am trying to extract the city out of a city state string. It works in most instances, but discovered it does not work in the below due to Colorado being in the city and also being the state. I need to make $geography_nav Colorado Springs and i also need it to work when the state is not part of the city string. Any idea on how to accomplish this?
$geography->description = Colorado
$geography->name- = Colorado Springs Colorado
$geography_nav=explode($geography->description, $geography->name);</code>
I am updating this, I don't necessarly need to use explode, just trying to find some way to extract the city out of the city state string. The format will always be the same as shown above in $Geography->name and the
$Geography->description will always equal the state name.
I utilized the strrpos function which searches for an instance of a string from the right.
This will work if you know that $geography->name definitely has the state that is at the end of $geography->description.