preview string with strlen PHP (help)

From: Date: Fri, 23 Mar 2007 15:18:16 +0000
Subject: preview string with strlen PHP (help)
Groups: php.general 
Request: Send a blank email to php-general+get-251180@lists.php.net to get a copy of this message
Dear All, I am very new to programming. I want to make a preview text that would display only a part of the text that is a text field in a database. //Begin Make preview string $minitxt = $row_show_cat['text']; $len = strlen($minitxt); if ($len > 235) { $len = 235; } else { $len = $len; } $newstring = substr($minitxt,0,$len); $previewtext = $newstring; //End Make preview string But if I want to display this somewhere in the page it will only display the first record of at every text column row <?php echo $previewstext ?> Althought I am very new to php and programming. I thought maybe I should rewrite it into a function. But my function won't work. function previewString($showcatvar) { $minitxt = $showcatvar; $len = strlen($minitxt); if ($len > 235) { $len = 235; } else { $len = $len; } $newstring = substr($minitxt,0,$len); $previewtext = $newstring; $previewtext = $whowcatvar; } and to display it in the page: <?php echo previewString($row_show_cat['text']) ?> IT displays notthing. But I think I am doing somthing wrong. I am assigning the wrong variables to the $row_show_cat['text']) ??? Please let me know

« previous php.general (#251180) next »