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
Re: string length [message #185324 is a reply to message #185321] Tue, 18 March 2014 15:57 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
On 18/03/14 15:11, Tim Streater wrote:
> In article <umgkqacqlbwl(dot)1erkg4bj91fbo$(dot)dlg(at)40tude(dot)net>, richard
> <noreply(at)example(dot)com> wrote:
>
>> What can I use to count the number of characters in a string?
>> strlen() does not seem to work properly.
>
> IME, it does.
>
>> 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.
>
> Suggest you give some examples which fail. You sure there are no
> unprintable characters in the filename?
>
> I've never had a problem with strlen.
>
IIRC and it may be wrong, strlen() gives the number of octets in the
string, which may fail for multi-byte character sets.

mb_strlen() returns the number of characters, if supplied with the
correct encoding.



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
[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: Wed Nov 27 20:49:23 GMT 2024

Total time taken to generate the page: 0.04218 seconds