当前位置: 动力学知识库 > 问答 > 编程问答 >

php - T_ENCAPSED_AND_WHITESPACE error

问题描述:

I'm trying to put the diff script into my website, from Paul Butler's website here: http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/

and it gives me the error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,

expecting ']' on line 138

line 38 is this

$matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1])

More lines before and after are:

 function diff($OLDHISTORY, $NEWHISTORY){

$maxlen = 0;

foreach($OLDHISTORY as $oindex => $ovalue){

$nkeys = array_keys($NEWHISTORY, $ovalue);

foreach($nkeys as $nindex){

// vvv ERROR LINE vvv

$matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ?

$matrix[$oindex - 1][$nindex - 1] + 1 : 1;

if($matrix[$oindex][$nindex] > $maxlen){

$maxlen = $matrix[$oindex][$nindex];

$omax = $oindex + 1 - $maxlen;

$nmax = $nindex + 1 - $maxlen;

}

}

}

if($maxlen == 0)

return array(array('d'=>$OLDHISTORY, 'i'=>$NEWHISTORY));

return

array_merge(

diff(

array_slice($OLDHISTORY, 0, $omax),

array_slice($NEWHISTORY, 0, $nmax)

),

array_slice($NEWHISTORY, $nmax, $maxlen),

diff(

array_slice($OLDHISTORY, $omax + $maxlen),

array_slice($NEWHISTORY, $nmax + $maxlen)

)

);

}

网友答案:

Fixed it, I forgot to close the echo between an html part and the function part. Shows up now, still not working right but I'm getting there

分享给朋友:
您可能感兴趣的文章:
随机阅读: