Forum Moderators: coopster

Message Too Old, No Replies

counting characters with return

trying to count characters and return a statement based on the answer

         

ProductivePC

11:12 am on May 31, 2004 (gmt 0)

10+ Year Member



I am having a little bit of trouble with a small script I wrote and I cannot figure out what is wrong with it.

I use the var $url to capture a specific URL's.

with that knowledge here is the script
<?php
if (count_chars($url)>100)
{
$title=$url;
$url= 'wwWebmasterWorldebsite.net/...';
}
echo $url
?>
now, this is supposed to return only if the characters are greater than 100 but it returns no matter what the characters are....

Can anyone see what I am going wrong?

Thanks

Wayne

henry0

11:38 am on May 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can aslo built your quest around of:

$string="webmasterworld";

$num_char=strlen($string);

echo $num_char;

Will output: 14

and then integrate the result in your script

ProductivePC

12:45 pm on May 31, 2004 (gmt 0)

10+ Year Member



Thank you for your reply. There is another thing that I would like to do but I am not sure how.... I am looking on php.net for a command that will parse the string up to the desired about and then cut it off.

so if
$string = 'webmasterworld'

I can have it output only

webmaster

if I choose.

Do you happen to know of a command that will work for that?

I am pretty sure that I can do that with substr();

ProductivePC

12:59 pm on May 31, 2004 (gmt 0)

10+ Year Member



yep, that was it.... I incorporated my php script with you said and used the substr() function.... thank you much for all of your help.

Wayne