FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » string length
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
string length [message #185320] Tue, 18 March 2014 14:45 Go to previous message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma:
Senior Member
What can I use to count the number of characters in a string?
strlen() does not seem to work properly.
count_chars() does several different things but does not count the total.
In BASIC I would use value=len(a$).
I've had a look at the string functions and don't see a one that does this.

what I'm looking to do is, read a directory and load an array based upon
certain conditions of the file name.

Using strlen and trying to match the file length to a fixed value does not
work for me.


$count=0;
$yr=1959;
while ($yr<=1969){
if ($handle = opendir('audio/'.$yr)) {
echo "Directory handle: $handle\n";
echo "Entries:\n";

/* This is the correct way to loop over the directory. */
while (false !== ($entry = readdir($handle))) {
$length=strlen($entry);
if ($length==10){
echo "$entry\n";
echo "<br>";
$count=$count+1;
}

}

closedir($handle);
}
$yr++;
}

echo $count;
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Nested PHP
Next Topic: weird global issue
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Oct 21 00:20:50 GMT 2024

Total time taken to generate the page: 0.08612 seconds