2014-01-30 54 views
-1

我有我的代碼正則表達式標籤和簡短的文字

$regex = '/<p>(.*?)<\/p>/si'; 
preg_match($regex, $products_description, $description); 
$p1 = strpos($description, ' ', 200); 
$p2 = substr($description, 0, $p1); 
$content = $p2[1]; 

的輸出一些問題,我希望有一個標籤之間來獲取文本和短期有200個字符。我不知道我做錯了什麼?

感謝

+0

**什麼是「問題」是什麼意思?**「問題」是一個描述不足以讓我們理解這個問題。當你嘗試時發生了什麼?你收到錯誤信息了嗎?你得到不正確的結果了嗎?你有沒有得到結果?如果結果不正確,是什麼使它們不正確?你想要什麼呢?你有沒有得到任何正確的結果?如果是這樣,他們是什麼?不要讓我們猜測。 –

+0

沒有任何結果。沒有回報 – karadayi

回答

0

我得到它的工作

//Find between a Tag the Text 
$regex = '/<p>(.*?)<\/p>/si'; 
preg_match($regex, $products_description, $description); 

//Short Text to max 150 characters 
$p2 = substr($description[1], 0, 150); 
$content = $p2;