I have the following PHP and JS:
<?php
    // Here's where the array of objects is built
    $depthElements = array(
        array('http://placehold.it/300x300',-150,100,0.8),
        array('http://placehold.it/200x300',-270,458,0.7)
    );
?>
<script>
var depthElems = <?php echo(json_encode($depthElements)); ?>;
</script>
It builds a multi-dimensional PHP array, and then packages them for the JS:
jQuery(document).ready(function($) { 
    // Create and position the elements on the page
    for (element in window.depthElems) {
        var a = window.depthElems[element];
        $('body').append('<img src="' + a[0] +
                         '" style="margin-left: ' + a[1] + 
                         'px; top: ' + a[2] + 
                         'px;" data-velocity="' + a[3] +
                         '" class="depthElem" />'); 
    }
    $(document).scroll(function () {
        var topDist = $(document).scrollTop();
        $('.depthElem').each(function () {
            $(this).css('margin-top', -topDist*($(this).attr('data-velocity')+'px'));
        });
    });
});
This seems to make sense to me, but for some reason there a bunch of extra elements on the page that I didn't ask for:

Where are they coming from?
 
     
     
    