Re: calculate bytes in string
| From: | @ Edwin | Date: | Sat, 09 Nov 2002 09:29:14 +0000 |
| Subject: | Re: calculate bytes in string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123563@lists.php.net to get a copy of this message | ||
Or,
"Jason Wong" <php-general@gremlins.com.hk> wrote:
> On Saturday 09 November 2002 14:22, Ian Newlands wrote:
> > Does anyone know of a function, or a method to calculate how many bytes
are
> > in a string? Similar to the filesize file system function.
> >
> > Any help would be appreciated.
>
> Assuming 1 character = 1 byte, then strlen().
>
Just write the string to a file first then check the filesize. This should
work (I think)
even if you're dealing with multi-byte characters wherein 1 character = 2
bytes
(or more?).
There's mb_strlen() but I don't think it'll be useful though...
- E