之前从字符串中获取nedele

时间:2013-10-01 09:09:27

标签: php string explode

如何通过在某事物之前获取针头来获取针头?

CODE:

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

我需要从字符串

获取quick

我试图使用爆炸但是你只能得到针头背后的东西。

4 个答案:

答案 0 :(得分:0)

echo substr($test, 0, strpos($test, '('));

答案 1 :(得分:0)

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

echo $result['0']; // The quick

答案 2 :(得分:0)

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

$substr =  substr($test, 0, strpos($test, '(') - 1);

答案 3 :(得分:0)

$substr = end(explode(' ', rtrim(strstr($test, '(', true), ' ')));