Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在“-”之前我怎样才能得到第一个值
例如:我有一个字符串,
$title = "9283-returns-to-normal-in-1989"; or $title = "83-returns-to-normal-in-1989"; or $title = "9283231-returns-to-normal-in-1989";
我只想获取该字符串中的第一个数值,直到“-”。所以,我只能得到9283,83或者9283231不管它有多少值。
9283
83
9283231
请帮忙
尝试这个:
strstr($title, '-', true);