Check if array is empty or exists
<p>For the first page load I need to check if there is <code>image_array</code> load last image, otherwise block preview buttons; alert user to push new image button; create empty array to put there images;</p>

<p>The problem is that <code>image_array</code> in the <code>else</code> fires all time. If array exists - it just overrides it, but alert dosent work.</p>

<pre><code>if(image_array.length &gt; 0)
    $('#images').append('&lt;img src="'+image_array[image_array.length-1]+'" class="images" id="1" /&gt;');
else{
    $('#prev_image').attr('disabled', 'true');
    $('#next_image').attr('disabled', 'true');
    alert('Please get new image');
    var image_array = [];
}
</code></pre>

<p>UPDATE
Before loading html i have something like this</p>

<pre><code>&lt;?php if(count($images) != 0): ?&gt;
&lt;script type="text/javascript"&gt;
    &lt;?php echo "image_array = ".json_encode($images);?&gt;
&lt;/script&gt;
&lt;?php endif; ?&gt;
</code></pre>
