2009-09-13 74 views

回答

5

您正在寻找substr函数,我会说。

在你的情况,这里有一个例子:

$string = 'one two three'; 
$numSymbols = 7; 

$res_string = substr($string, 0, $numSymbols); 
var_dump($res_string); 

,你会得到:

string 'one two' (length=7) 

参数:

  • 字符串从
  • 提取物第一个字符的位置;即0,如果你想在
  • 字符数你想要的字符串的开头开始:7
+0

* “在你* R *案” – arbales 2009-09-13 09:09:56

+0

@arbales:这是尝试键入太快的问题:-(谢谢!我编辑了这个错字(和其他一些错误) – 2009-09-13 09:11:19

2

使用PHP的方法substr

$string = 'one two three'; 
$numSymbols = 7; 
$res_string = substr($string, 0, $numSymbols); 
2

您应该使用substr( )

例子:

$string = 'one two three'; 
$res_string = substr($string, 0, 7);// $res_string == 'one two'