keep getting MAX timeout error on urlencode
<p>I keep getting an error on this code: </p>

<pre><code>&lt;?php 
function encode_object(&amp;$obj) {
  foreach ($obj as &amp;$current) {
    if (is_string($current) or is_object($current) or is_array($current)) {
      if (is_object($current) or is_array($current)) {
        encode_object($current);
      }
      if (is_string($current)) {
        $current = urlencode($current);
      }
    }
  }
}
?&gt;
</code></pre>

<p>This code has worked before but for some reason every time a run it I get:</p>

<blockquote>
  <p>Fatal error: Maximum execution time of 30 seconds exceeded in * on line 9</p>
</blockquote>

<p>What I'm trying to do is be able to give it an object, search through it and encode all of the strings.</p>

<p>I have tried multiple times but keep getting the same error</p>

<p>I am using: 
Apache 2.2.15.0
PHP 5.3.3
Windows 7 Ultimate build 7600</p>

<p>EDIT:
The input I'm entering is an error that, after going through this function, is meant to be converted into JSON and read by javascript through ajax.
The input in this case would be: </p>

<pre><code>array("error"=&gt;
  array(
    "error"=&gt;"error",
    "number"=&gt;2,
    "message=&gt;"json_encode() [&lt;a href='function.json-encode'&gt;function.json-encode&lt;\/a&gt;]: recursion detected",
    "line"=&gt;22))
</code></pre>

<p>That is another error that i will worry about later, but it seems that when I put 
  $obj['error']['message'] = 'blah';
on the object before I send it, the code works fine. So there is something about </p>

<pre><code>  json_encode() [&lt;a href='function.json-encode'&gt;function.json-encode&lt;\/a&gt;]: recursion detected
</code></pre>

<p>that urlencode seems to be having a problem with.</p>
