Re: preview string with strlen PHP (help)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, March 23, 2007 10:18 am, Dwayne Heronimo wrote:
> function previewString($showcatvar) {
>
>  $minitxt = $showcatvar;
>  $len = strlen($minitxt);
>
>  if ($len > 235)
>  {
>   $len = 235;
>  }
>  else
>  {
>   $len = $len;
>  }

Take out this whole "else" block -- Assigning a variable to itself is
just silly.

>  $newstring = substr($minitxt,0,$len);
>
>  $previewtext = $newstring;
>
>  $previewtext = $whowcatvar;

You need to RETURN some value here, for the function to give back the
"answer" so that your echo below has something to print out.

http://php.net/return


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux