AdRock Posted July 2, 2010 Share Posted July 2, 2010 function ShortenText($text, $chars) { $text = $text." "; $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } $placeholders = array($keywords, $uckeywords); $vals = array("<span class='searchbold'>$keywords</span>", "<span class='searchbold'>$uckeywords</span>"); $link = str_replace($placeholders, $vals, $title); $add = str_replace($placeholders, $vals, $content); $add = ShortenText(str_replace('&', '&',$add,500); How do i fix the error Only variables can be passed by reference? I want to replae the keywords with bold text and also change the ampersands to & Link to comment https://forums.phpfreaks.com/topic/206572-only-variables-can-be-passed-by-reference/ Share on other sites More sharing options...
kenrbnsn Posted July 2, 2010 Share Posted July 2, 2010 I believe you've forgotten a closing ")" in this line <?php $add = ShortenText(str_replace('&', '&',$add,500); ?> try <?php $add = ShortenText(str_replace('&', '&',$add),500); ?> Ken Link to comment https://forums.phpfreaks.com/topic/206572-only-variables-can-be-passed-by-reference/#findComment-1080490 Share on other sites More sharing options...
AdRock Posted July 2, 2010 Author Share Posted July 2, 2010 I saw that but that wasn't the problem I had to do the str_replace first then call the function but it now works Link to comment https://forums.phpfreaks.com/topic/206572-only-variables-can-be-passed-by-reference/#findComment-1080501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.