php - How can i escape from endless loop? -


i'm trying create suffixer(name make). url exploder below..

private function explode_url() {      if (!empty($this->suffix) , empty($is)) {                                              // here  ------v         $url = explode('/', rtrim($_get['url'], $this->define_suffix()));      } else {         $url = explode('/', trim($_get['url'], '/'));     }     $str = '';     foreach ($url $key => $value) {         if ($key >= 2) {             $str = $str . '/' . $value;         } else {             $data[] = $value;         }     }     $data[] = trim($str, '/');     foreach ($data $data) {         if (!empty($data)) {             $result[] = $data;         }     }     return $result; } 

and here function defines suffix.

private function define_suffix() {         $count = count($this->explode_url()); // <------ here         $count = $count - 1;         $keys = array('cnt', 'mtd', 'args');         return $this->suffix[$keys[$count]];     } 

actually functions work there problem. there endless loop. how can escape this?

edit: output:

fatal error: allowed memory size of 134217728 bytes exhausted (tried allocate 130968 bytes) in /var/www/cleanmvc/boot.php on line 85 

the functions call each other, causing infinite loop. that's need with.

the keyword escape loops break. if you're nested within loops, can break multiple loops child loops passing optional parameter in: break(2) - breaks out of 2 levels.

your infinite loop here: foreach ($data $data) {


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -