我有下面的代码,我试图从城市状态字符串中提取城市。它在大多数情况下都有效,但发现它在下面不起作用,因为科罗拉多州在城市中并且也是州。我需要制作$geography_nav
科罗拉多斯普林斯,并且当该州不属于城市字符串时,我还需要它来工作。关于如何做到这一点的任何想法?
$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
将始终等于州名。