I'm trying to pull images for my friends flicker account from all of the pages there. I'm only able to pull them from the first page though. Does anyone see why this isn't working?

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
#images {
border:#000000 solid 1px;
width:350px;
height:350px;
padding:10px;
}
</style>
</head>
<body>
<div id="images">
<?php
    $user_name 
'USERACCOUNT';
    
$page_is "http://www.flickr.com/photos/$user_name/page1/";
    
$page file_get_contents($page_is);
    
$pages_number explode('class="Paginator'$page);
    
$pages_value preg_replace('/.*(\d+)<\/a>\n\t\t<a.*?class="Next">.*/s''$1'$pages_number[1]);
    
settype($pages_value"integer");
    
$pages_value++; //increase because page starts at page1
    
for ($count_at =1$count_at $pages_value$count_at++) {
        
$page_is "http://www.flickr.com/photos/$user_name/page$count_at/";
        
$page file_get_contents($page_is);
        
$pattern '/<table width="100%" cellspacing="0" cellpadding="0" class="PhotoStream ps-photos-only">/';
        
$patterns[] = '/\n/';
        
$replacements[] = '';
        
$patterns[] = '/\t/';
        
$replacements[] = '';
        
$patterns[] = '/<tr .*?>/';
        
$replacements[] = '';
        
$patterns[] = '/<td.*?>/';
        
$replacements[] = '';
        
$patterns[] = '/<\/tr>/';
        
$replacements[] = '';
        
$patterns[] = '/<\/td>/';
        
$replacements[] = '';
        
$patterns[] = '/<table .*?>/';
        
$replacements[] = '';
        
$patterns[] = '/<span .*?>/';
        
$replacements[] = '';
        
$patterns[] = '/<\/span>/';
        
$replacements[] = '';
        
$patterns[] = '/<\/table>/';
        
$replacements[] = '';
        
$patterns[] = '/<a .*?>/';
        
$replacements[] = '';
        
$patterns[] = '/<\/a>/';
        
$replacements[] = '';
        
$patterns[] = '/<(h\d).*?>.*?<\/\1>/';
        
$replacements[] = '';
        
$patterns[] = '/<\/div>/'
        
$replacements[] = '';
        
$patterns[] = '/<p.*?>.*?<\/p>/';
        
$replacements[] = '';
        
$patterns[] = '/<script.*?>.*?<\/script>/';
        
$replacements[] = '';
        
$patterns[] = '/(<img src=".*?>)<img src=".*?\.gif" .*?>/';
        
$replacements[] = '$1';
        
$patterns[] = '/<div.*?>/';
        
$replacements[] = '';
        
$patterns[] = '/(<img src=".*?>).*?(<)/';
        
$replacements[] = '<div class="img">$1' "\n" '$2';
        
$patterns[] = '/(<img src=".*?>).*?(<)/';
        
$replacements[] = '<div class="img">$1' "\n" '$2';
        
$patterns[] = '/<div class="img"><div class="img">/';
        
$replacements[] = '<div class="img">';
        
$patterns[] = '/\s\s/';
        
$replacements[] = '';
        
$page preg_replace($patterns$replacements$page);
        
$page preg_replace('/<tr>pretty lat\/long/'''$page);
        
$images[] = $page;
    }
    
$page implode($images);
    
$page preg_split('<br clear="all" />'$page);
    
$page preg_split('<div class="img">'$page[0]);
    
$total count($page);
    for (
$i 1$i $total$i++) {
        
$page[$i] = str_replace('><img''<img'$page[$i]);
        
$page[$i] = preg_replace('/\/>\n</''/>' "\n"$page[$i]);
        
$page[$i] = preg_replace('/"class="/''" class="'$page[$i]);
        
$page[$i] = preg_replace('/border="0" \/>/''border="0" ' "id=\"image_$i\" />"$page[$i]);
        
$width[$i] = preg_replace('/.* width="(\d+)".*/'"$1"$page[$i]);
        
$height[$i] = preg_replace('/.* height="(\d+).*"/'"$1"$page[$i]);
        
$page[$i] = preg_replace('/ width="\d+"/'' width="' $width[$i]/1.5 '"'$page[$i]); 
        
$page[$i] = preg_replace('/ height="\d+"/'' height="' $height[$i]/1.5 .'"'$page[$i]);
    }
    unset(
$page[0]);
    unset(
$page[1]);
    
shuffle($page);
    echo 
$page[1];
    echo 
$page[2];
    echo 
$page[3];
    echo 
$page[4];
?>
</div>
</body>
</html>