正如我切換到PHP7我有問題(未捕獲的錯誤:調用未定義的函數額日格())EREG到的preg_match PHP7
我的問題是如何從的preg_match改變,因爲當我改變的preg_match(「[0- 9] {1,2}」,$頭)我得到的輸出........
我下面的代碼:
$prevodi = explode('@',$word['prevod']);
foreach ($zborovi as $zbor)
{
$atr = "";
echo '<div class="words">';
$tmpprev = $prevodi[$cnt];
$pred = preg_split("[.]",trim($tmpprev));
$len = strlen($tmpprev);
$cut = 0;
$lng = count($pred);
if ($lng > 1)
{
$cnt1 = 0;
while ($cnt1 < $lng-1)
{
$head = trim($pred[$cnt1]);
$cut = $cut + strlen($pred[$cnt1]) + 1;
$cnt1 = $cnt1 + 1;
if (preg_match("/\d{1,2}/", $head)) continue;
if (strpos($head,'(') === false || strpos($head,'(е)') !== false) $atr = $atr.$head.'. ';
}
}
echo '<span class="zbor_1">'.$zbor.'<span class="atribute"> '.$atr.'</span></span><br />';
包裹既然你切換到PHP 7,很明顯,因爲'PHP 5.3.0 ereg'已被棄用。 'ereg'沒有正則表達式分隔符。 'preg_match'需要分隔符'/'或'#',這樣就可以像'preg_match(「/ [0-9] {1,2} /」,$ head)'或'preg_match(「#[0-9 ] {1,2}#「,$ head)'。 – Perumal
@ Perumal93這正是我的答案:)你可以投票,你知道... – Dekel
我已經在你回答之前輸入它。一旦你回答,該帖子被擱置,以避免進一步得到任何答案。因此我無法發佈答案,並認爲至少要提供評論意見。順便說一下,我不反對對你的答案進行投票。完成。 :) – Perumal