homepage Welcome to WebmasterWorld Guest from 54.226.166.224
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




msg:1257850
 11:12 am on May 31, 2004 (gmt 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

 

henry0




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

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




msg:1257852
 12:45 pm on May 31, 2004 (gmt 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();

ProductivePC




msg:1257853
 12:59 pm on May 31, 2004 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved