2009-09-13 73 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'