Welcome to WebmasterWorld Guest from 54.225.3.114

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

counting characters with return

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

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

Junior Member

10+ Year Member

joined:May 30, 2004
posts:64
votes: 0


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

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

Senior Member from US 

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 19, 2003
posts:4407
votes: 5


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

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

Junior Member

10+ Year Member

joined:May 30, 2004
posts:64
votes: 0


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();

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

Junior Member

10+ Year Member

joined:May 30, 2004
posts:64
votes: 0


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