我怎样才能通过在某物之前得到它来从绳子中取出一根针?
代码:
$test = "The quick (brown fox jumps over the lazy dog)";
我需要quick
从字符串中获取 The
我曾尝试使用爆炸,但你只能得到针后面的东西。
echo substr($test, 0, strpos($test, '('));
$test = "The quick (brown fox jumps over the lazy dog)";
$result = explode("(", $test);
echo $result['0']; // The quick
$test = "The quick (brown fox jumps over the lazy dog)";
$substr = substr($test, 0, strpos($test, '(') - 1);
$substr = end(explode(' ', rtrim(strstr($test, '(', true), ' ')));