PHP - end of string (null byte)
<p>How to find out end of PHP string? I have one task: recognize string length without any functions. I know all strings in PHP ends with null byte ("\0"), but I can't know elements of string after last symbol.
For example, this will not work:</p>

<pre><code>while($a[++$length]);
</code></pre>

<p>How to know length of string without using any functions?</p>

<p>I find one solution now:</p>

<pre><code>$lenght = -1;
while (true)
{
    if ($a[++$length] == "") break;
}
</code></pre>

<p>Thanks for answers, the best way, in my opinion, is</p>

<pre><code>$length = 0;
while ($string[$length] !="")
{
   $length++;
}
</code></pre>

<p>or </p>

<pre><code>$length = -1;
while ($string[++$length] !="");
</code></pre>
