form error Fatal error: Cannot use string offset as an array It's pretty stright forward, im trying to display the results of my form, Im having trouble finding something that explains how to display the results outside of the  drupal_set_message() code, I think I am close with my current code.However I am getting this error Fatal error: Cannot use string offset as an array

/** 
 * Block info 
 */ 

function zillow_block_info(){
    $blocks['zillow_block'] = array(
        'info' =&gt; t('Zillow Block'),
    );
    return $blocks;
}

function zillow_block_view($delta = ''){
    $block = array();
        switch ($delta){
    case 'zillow_block';
        $block['subject'] = t('Zillow Block');
        $block['content'] = drupal_get_form('zillow_form');
    break;
    }
    return $block;
}

/**
 * Api info 
*/

function zillow_api_info($form, &amp;$zinfo){
    set_time_limit(3600);
    $state = $zinfo['values']['state'];
    $zillow_id = 'XXXXXXXXXXX';
    $xml = file_get_contents('http://www.zillow.com/webservice/GetRateSummary.htm?zws-id='.$zillow_id.'&amp;state='.$state.'');
    $zinfo = simplexml_load_string($xml);

    foreach($zinfo-&gt;response as $rates){
        $zinfo .= $rates-&gt;today-&gt;rate[0];
        $zinfo .= $rates-&gt;today-&gt;rate[1];
        $zinfo .= $rates-&gt;today-&gt;rate[2];
        $zinfo .= $rates-&gt;lastWeek-&gt;rate[0];
        $zinfo .= $rates-&gt;lastWeek-&gt;rate[1];
        $zinfo .= $rates-&gt;lastWeek-&gt;rate[2];
    }

    return $zinfo;
}

/**
 * Form
 */

function zillow_form($form, &amp;$zinfo){

    $form['description'] = array(
        '#type' =&gt; 'item',
        '#title' =&gt; t('Get your mortgage rates'),
    );
    $form['rates'] = array(
        '#type' =&gt; 'fieldset',
        '#title' =&gt; t('Mortgage Rates'),
        '#collapsiable' =&gt; TRUE,
        '#collapsed' =&gt; FALSE,
    );

    $form['rates']['state'] = array(
        '#type' =&gt; ('select'),
        '#title' =&gt; t('Choose One'),
        '#options' =&gt; array( 
            'AK' =&gt; t('Alaska'),  
            'AZ' =&gt; t('Arizona'),
        ),
        '#required' =&gt; TRUE
    );
    $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Submit'),
    );
    if(isset($zinfo['values'])){
        $form['page_output'] = array(
        'markup' =&gt; 'Submitted value:'. $zinfo['values']['state']); 
    }
    return $form;
}

/**
 * Submission Output    
*/

function zillow_form_submit($form, &amp;$zinfo){
  drupal_set_message(t('this is the info the form has submitted. states=@states, todaysrates=@todaysrates', array('@states' =&gt; $zinfo['values']['state'], '@todaysrates' =&gt; zillow_api_info($form, $zinfo))));
  $zinfo['processed']['states'] =  serialize($zinfo['values']['state']);
  $zinfo['processed']['todaysrates'] =  serialize(zillow_api_info($form, $zinfo));
}


Edit** My code has been modified I am now only getting this error
The problem is here:

if(isset($zinfo['values'])){
    $form['page_output'] = array(
    'markup' =&gt; 'Submitted value:'. $zinfo['values']['state']); 
}


Any element of a render-array that doesn't start with a # symbol is itself considered a child render-array by the drupal_render() function.

As drupal_render() expects an array when your array key is markup (without the #), it tries to treat the variable as an array. Since it's a string, PHP complains that it can't use the provided variable as an array...because it isn't one :)

This should work:

if(isset($zinfo['values'])){
    $form['page_output'] = array(
    '#markup' =&gt; 'Submitted value:'. $zinfo['values']['state']); 
}


Have a look at Render Arrays in Drupal 7 and the FAPI #markup property for more information.

EDIT

There's a slightly bigger problem: in zillow_api_info() you're accepting the $zinfo parameter by reference, and then overwriting it with this call: $zinfo = simplexml_load_string($xml);.

That code overwrites the $zinfo variable in memory, so when you use it again in your submission function it will cause errors. It's also what's causing the last two lines not to work, and $zinfo['values'] to not exist when your form is rebuilt.

The easiest solution is to change zillow_api_info() to look like this:

function zillow_api_info($form, &amp;$form_state){
  set_time_limit(3600);
  $state = $form_state['values']['state'];
  $zillow_id = 'XXXXX';
  $xml = file_get_contents('http://www.zillow.com/webservice/GetRateSummary.htm?zws-id='.$zillow_id.'&amp;state='.$state.'');
  $zinfo2 = simplexml_load_string($xml);

  foreach($zinfo2-&gt;response as $rates){
    $zinfo2 .= $rates-&gt;today-&gt;rate[0];
    $zinfo2 .= $rates-&gt;today-&gt;rate[1];
    $zinfo2 .= $rates-&gt;today-&gt;rate[2];
    $zinfo2 .= $rates-&gt;lastWeek-&gt;rate[0];
    $zinfo2 .= $rates-&gt;lastWeek-&gt;rate[1];
    $zinfo2 .= $rates-&gt;lastWeek-&gt;rate[2];
  }

  return $zinfo2;
}


As an extra note, you do need $zinfo['rebuild'] = TRUE in your submit function too.

I'd really advise using the $form_state variable name throughout your code when it refers to the form state array, it'll make problems like this vanish instantly :)