Formatting some data about some airlines
function reformat($data, $registration = false) {
    // Initializing aircompanies codes
    $iata = new iata;
    $block = array();
    for ($i = 0; $i &lt; count($data); $i += 6) {
        $block[$i] = array(
            'airport'  =&gt; $this-&gt;prep_value($data[$i + 1]),
            'terminal' =&gt; substr(strrev($this-&gt;prep_value($data[$i + 2])), 2, 1),
            'shedtime' =&gt; $this-&gt;prep_value($data[$i + 3]),
            'facttime' =&gt; str_replace('&amp;nbsp;', '', $this-&gt;prep_value($data[$i + 4])),
            'status'   =&gt; str_replace(';', '', 
                              str_replace('&amp;nbsp', '&lt;br /&gt;', 
                                  trim(
                                      strip_tags($this-&gt;prep_value($data[$i + 5]), '&lt;img /&gt;'), 
                                      '&amp;nbsp;/r/n'
                                  )
                              )
                          ),
        );

        if ($registration) {
            $r = str_replace('&lt;nobr&gt;', '', $this-&gt;prep_value($data[$i]));
            $block[$i]['reis'] = str_replace('&lt;/nobr&gt;', '', $r);
            $a = explode(' ', trim($block[$i]['reis']));
            $block[$i]['company'] = $a[0];
        } else {
            $r = explode('&amp;nbsp;', $this-&gt;prep_value($data[$i]));
            $block[$i]['company'] = (strlen($r[0]) &gt; 2) ? substr($r[0], -17, 2) : $r[0];
            $block[$i]['reis'] = $block[$i]['company'] . ' ' . $r[1];
        }
        $block[$i]['companyname'] = $iata-&gt;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-&gt;prep_value($data[$i + 2])


It is really bad idea. May be you need a little another cycle, like

for ($i = 0; $i &lt; count($data) - 6; $i ++) { // or something for preventing array index overloading


It would be much better.
But I cannot know it for sure.