// echo "test"; // die(); $response = get_web_page1( 'http://arc.sgfclients.com' . str_replace( 'accessories_filter_pdf', 'accessories_filter_pdf_data', $_SERVER['REQUEST_URI'] ) ); /*$response = str_replace( ']', '}', str_replace( '[', '{', $response ) ); $response = preg_replace( "/\r|\n/", "", $response ); $products = json_decode($response);*/ function get_web_page1($url){ $user_agent='Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0'; $options = array( CURLOPT_CUSTOMREQUEST =>"GET", //set request type post or get CURLOPT_POST =>false, //set to GET CURLOPT_USERAGENT => $user_agent, //set user agent CURLOPT_COOKIEFILE =>"cookie.txt", //set cookie file CURLOPT_COOKIEJAR =>"cookie.txt", //set cookie jar CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } $response = str_replace( ']', '}', str_replace( '[', '{', $response['content'] ) ); // print_r($response);die(); $response = preg_replace( "/\r|\n/", "", $response ); $products = json_decode($response); $products = json_decode(json_encode($products), true); // print_r($products);exit; // SETUP ALL VARIABLES foreach( $products as $product ) : // TITLE $vars['title'] = $product['title']; // DESCRIPTION $vars['description'] = $product['description']; // IMAGES $vars['images']['main'] = $product['product_image']; // FILTER VARIABLES $print_var['filters'] = $print_var['options'] = ''; $count = 0; foreach( $product['filters'] as $filter ) : if( $vars['title'] == "bffvx") : $vars['filter_title'] = $vars['title']; foreach( $filter['options'] as $filter_key => $filter_value ) : if( $filter_value != 'false' ) $print_var['options'] .= '