-1

我怎样才能通过在某物之前得到它来从绳子中取出一根针?

代码:

$test = "The quick (brown fox jumps over the lazy dog)";

我需要quick从字符串中获取 The

我曾尝试使用爆炸,但你只能得到针后面的东西。

4

4 回答 4

0
echo substr($test, 0, strpos($test, '('));
于 2013-10-01T09:13:28.973 回答
0
$test = "The quick (brown fox jumps over the lazy dog)";
$result = explode("(", $test);

echo $result['0']; // The quick
于 2013-10-01T09:13:36.227 回答
0
$test = "The quick (brown fox jumps over the lazy dog)";

$substr =  substr($test, 0, strpos($test, '(') - 1);
于 2013-10-01T09:17:28.950 回答
0
$substr = end(explode(' ', rtrim(strstr($test, '(', true), ' ')));
于 2013-10-01T09:28:28.163 回答