Meep3D Posted January 18, 2007 Share Posted January 18, 2007 I am trying to import a datafile which is similar to a php array in structure, but is saved in a text file. e.g... (the following isn't the actual file its just an interpretation.[code]BSI = { ["n1"] = { ["m1"] = { ["o1"] = 0, }, ["m2"] = { ["o2"] = 0, } }}[/code]I use a recursive function within a class to split it into the array(). The actual function works, it returns the first result split properly. The problem occurs with the recursion - as soon as the function calls itself it dies. It runs for a few seconds then displays nothing at all. Even a <h1> tag at the top, outside the PHP block doesn't display. It simply dies on a blank screen with no warnings or errors (I have E_ALL on. I am thinking it's an issue with PHP/Apache as it should at least give me an error. Code is below.I put ...echo '<p>This Point Here</p>';...in to basically show me how many recursions it's done. If I comment out the line below which tells it to recurse...$contents = $this->parseStatement ( $contents );...then the page renders fine with 'This Point Here' once. If I leave it uncommented, I just get a blank screen.Thanks in advance if you can help!(Hi BTW, I am new)[code] function parseStatement ( $statement ) { $literalString = false; $readMode = true; $currentString = ''; $valueString = ''; $indent = 1; $contents = ''; $openCurly = false; $openSquare = false; $return = ''; # Loop for each character. for ( $counter = 0; $counter < strlen ( $statement ); $counter++ ) { $char = substr ( $statement, $counter, 1 ); $readMode = true; # Parse single quotes. if ( $char == '"' ) { $literalString = !$literalString; $readMode = true; } # Parse characters (if not in literal string) if ( !$literalString && ( $char == '=' ) ) { $readMode = false; $valueString = $currentString; $currentString = ''; } # echo $char; if ( !$literalString && ( $char == '{' ) ) { $readMode = false; $endCurly = $this->matchBrace ( $statement, '{}', $counter+1 ); $contents = substr ( $statement, $counter + 1, $endCurly - $counter - 2 ); # echo 'BREAK'; break; } # Add current to string if required. if ( $readMode ) $currentString .= $char; } echo '<p>This Point Here</p>'; $contents = $this->parseStatement ( $contents ); if ( $valueString ) { $return = array ( $valueString => $contents ); } else { $return = $contents; } return $return; }[/code]Sorry about the lack of commenting, it should be fairly obvious though. Link to comment https://forums.phpfreaks.com/topic/34728-recursive-script-causing-nothing/ Share on other sites More sharing options...
Meep3D Posted January 18, 2007 Author Share Posted January 18, 2007 PHP 5 on Apache2.2 on Windows XP btw. Link to comment https://forums.phpfreaks.com/topic/34728-recursive-script-causing-nothing/#findComment-163658 Share on other sites More sharing options...
Meep3D Posted January 18, 2007 Author Share Posted January 18, 2007 Sorry I am an idiot. I just realized it calls itself forever. If only it told me that or gave some sort of error. Ah well... Link to comment https://forums.phpfreaks.com/topic/34728-recursive-script-causing-nothing/#findComment-163664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.