user6582353 user6582353 - 1 month ago 17
PHP Question

Error Php shorten text function, need correction

I'm not sure where I'm missing.

I've try looking at the syntax and also the miss spelling function name

but it seems I can't find that problems

the problem is come from line 4 coding

<?php

function shortenText($text, $maxlength=70, $appendix = "..."){
$text = strip_tags($text);
if(mb_strlen($text) <= $maxlength){return $text;}
$text = mb_substr($text, 0, $maxlength - mb_strlen($appendix));
$text =. $appendix;
return $text;
}

}

Answer

fourth line must be : $text.= $appendix;

edit: just saw comment.I guess it was before I could complete my post.