Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes)
<p>i have made a function will return N-th digit of sequence number, example :</p>

<p>1234567891011121314151617</p>

<ul>
<li>The 5-th digit is 5</li>
<li>The 20-th digit is 1 </li>
</ul>

<p>My function is like this </p>

<pre><code> &lt;?php
   function getLength($number) {
   $length = 0;
   if ($number == 0){
      $length = 1;
   } else {
      $length = (int) log10($number)+1;
   }
     return $length;
  }
 ?&gt;

&lt;?php
 function getDigitNumber($digit){
   $number = 10000000000;
   $data = array();
   for($i=1;$i&lt;=$number;$i++){  
   if(getLength($i) &gt; 1){
     $array = str_split($i,1);
    for($n=0;$n&lt;=count($array)-1;$n++){
        array_push($data,$array[$n]);
    }   
}else{
    $data[$i] = $i;
}
  } 
return $data[$digit];
}
?&gt;
</code></pre>

<p>When i executed that i've a problem like this error message "Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes)". Maybe because i assign a large number in var <code>$number</code></p>

<p>How can i fix that..or how can i make function that can handle these large number</p>

<p>thanks..</p>
