Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 03-15-2005, 11:09 PM   #1
PSD
PornSiteDomains.com
 
PSD's Avatar
 
Industry Role:
Join Date: Oct 2002
Location: US
Posts: 1,265
php question ...

Anyone know of a function that will count only the number of letters in a string and only the number of digits in a string?
PSD is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-16-2005, 01:13 AM   #2
etech
Confirmed User
 
Join Date: Feb 2004
Location: Right next to you....
Posts: 1,148
PHP Code:
$variable strlen("TestString"); 
strlen will return the number of characters in the string
etech is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-16-2005, 01:40 AM   #3
broke
Confirmed User
 
Join Date: Aug 2003
Location: Someplace Windy
Posts: 4,501
PHP Code:

<?php

  $str 
"00jkjdj0";
  
  
$char_count 0;
  
$num_count 0;
  
  
$u_bound strlen$str ) - 1;
  
  for( 
$i $i <= $u_bound $i++ ) {
  
    if( 
is_numeric$str$i } ) ) { $char_count++; } else { $num_count++; }
  
  }
  
  echo 
$char_count;
  echo 
$num_count;
  
?>
broke is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-16-2005, 01:51 AM   #4
broke
Confirmed User
 
Join Date: Aug 2003
Location: Someplace Windy
Posts: 4,501
Sorry. I mixed up my variabless in the following line (unless you want to use $char_count as the number count variable and $num_count as the character count variable ) ...

PHP Code:
if( is_numeric$str$i } ) ) { $char_count++; } else { $num_count++; } 
It should read...

PHP Code:
if( is_numeric$str$i } ) ) { $num_count++; } else { $char_count++; } 


Full code:

PHP Code:

  $str 
"00jkjdj0";
  
  
$char_count 0;
  
$num_count 0;
  
  
$u_bound strlen$str ) - 1;
  
  for( 
$i $i <= $u_bound $i++ ) {
  
    if( 
is_numeric$str$i } ) ) { $num_count++; } else { $char_count++; }
  
  }
  
  echo 
$char_count;
  echo 
$num_count
broke is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-16-2005, 01:54 AM   #5
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
Its cheaper to outsource the job to eager young pakistani counting experts
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.