如何在-
之前提取每个单词。我的意思是如果我有
word - word word
or
word word2 - word word
or
word word2 word3 - word word
我需要-
答案 0 :(得分:1)
<?php
$line="word word2 word3 - word word";
$words=explode(" ",trim(substr($line,0,strpos($line,"-"))));
print_r($words);
?>
<强> Demo 强>
一个班轮
print_r(explode(" ",trim(substr($line,0,strpos($line,"-")))));