function reformat($data, $registration = false) {    // Initializing aircompanies codes    $iata = new iata;    for ($i = 0; $i < count($data); $i = $i + 6) {        if ($registration) {            $r = str_replace('<nobr>', '', $this->prep_value($data[$i]));            $block[$i]['reis'] = str_replace('</nobr>', '', $r);            $a = explode(' ', $block[$i]['reis']);            $block[$i]['company'] = $a[0];        } else {            $r = explode('&nbsp;', $this->prep_value($data[$i]));            $block[$i]['reis'] = (strlen($r[0]) > 2) ? strrev(substr(strrev($r[0]), 15, 2)) . ' ' . $r[1] : $r[0] . ' ' . $r[1];            $block[$i]['company'] = (strlen($r[0]) > 2) ? strrev(substr(strrev($r[0]), 15, 2)) : $r[0];        }        $block[$i]['companyname'] = $iata->aircompanies[strtoupper($block[$i]['company'])];        if (file_exists(ROOT_HTML_PATH . '/content/aircompanies/' . $block[$i]['company'] . '.png')) {            $block[$i]['company'] = $block[$i]['company'] . '.png';        } else {            /**             * @todo Write e-mail notifications, but only once;             */        }        $block[$i]['airport'] = $this->prep_value($data[$i + 1]);        $block[$i]['terminal'] = substr(strrev($this->prep_value($data[$i + 2])), 2, 1);        $block[$i]['shedtime'] = $this->prep_value($data[$i + 3]);        $block[$i]['facttime'] = str_replace('&nbsp;', '', $this->prep_value($data[$i + 4]));        $block[$i]['status'] = str_replace('&nbsp', '<br />', trim(strip_tags($this->prep_value($data[$i + 5]), '<img />'), '&nbsp;/r/n'));        $block[$i]['status'] = str_replace(';', '', $block[$i]['status']);    }    return $block;}
Formatting some data about some airlines
php;formatting
function reformat($data, $registration = false) {    // Initializing aircompanies codes    $iata = new iata;    $block = array();    for ($i = 0; $i < count($data); $i += 6) {        $block[$i] = array(            'airport'  => $this->prep_value($data[$i + 1]),            'terminal' => substr(strrev($this->prep_value($data[$i + 2])), 2, 1),            'shedtime' => $this->prep_value($data[$i + 3]),            'facttime' => str_replace('&nbsp;', '', $this->prep_value($data[$i + 4])),            'status'   => str_replace(';', '',                               str_replace('&nbsp', '<br />',                                   trim(                                      strip_tags($this->prep_value($data[$i + 5]), '<img />'),                                       '&nbsp;/r/n'                                  )                              )                          ),        );        if ($registration) {            $r = str_replace('<nobr>', '', $this->prep_value($data[$i]));            $block[$i]['reis'] = str_replace('</nobr>', '', $r);            $a = explode(' ', trim($block[$i]['reis']));            $block[$i]['company'] = $a[0];        } else {            $r = explode('&nbsp;', $this->prep_value($data[$i]));            $block[$i]['company'] = (strlen($r[0]) > 2) ? substr($r[0], -17, 2) : $r[0];            $block[$i]['reis'] = $block[$i]['company'] . ' ' . $r[1];        }        $block[$i]['companyname'] = $iata->aircompanies[strtoupper($block[$i]['company'])];        if (file_exists(ROOT_HTML_PATH . '/content/aircompanies/' . $block[$i]['company'] . '.png')) {            $block[$i]['company'] = $block[$i]['company'] . '.png';        } else {            /**             * @todo Write e-mail notifications, but only once;             */        }    }    return $block;}But it is many questions here: $this->prep_value($data[$i + 2])It is really bad idea. May be you need a little another cycle, likefor ($i = 0; $i < count($data) - 6; $i ++) { // or something for preventing array index overloadingIt would be much better.But I cannot know it for sure.