how to store wordpress loop in array?

Use get_posts instead –

You can use the function get_posts() to get all the posts as array. This function accepts almost all parameters that of query post’s.

Example –

    $args = array( 'numberposts' => 3,'category' => 3 );
    $homePost = get_posts( $args );
    $one = $homePost[0]; 
    $two = $homePost[1]; 
    $three = $homePost[2];

    //print_r($one);        // lets see what we have in array - $one

    //e.g. to print the title
    echo $one->post_title; 

Note –

In this case you’ll not be able to use typical WordPress function’s like the_title(), the_excerpt() etc. You have to manually echo each element of array.

Tip – Do a quick print_r(); to see what else you have in array and use it.

error code: 523