3v4l.org

run code in 300+ PHP versions simultaneously
<? // Make array of URLs to work with $URLs = array( 'http://zonzoo.nl/uw-telefoons-verkopen/1023/Apple+iPhone+4+16GB', 'http://zonzoo.nl/uw-telefoons-verkopen/1024/Apple+iPhone+4+32GB', 'http://zonzoo.nl/uw-telefoons-verkopen/1272/Apple+iPhone+4+8GB' ); // Loop through each array and store the prices in arrays foreach ($URLs as $URL) { $working[] = do_shortcode('[wpwg url="' . $URL . '" selector=".price-quote.working dd" cache="0" rem_tags="script, style" newtab="false"]'); $not_working[] = do_shortcode('[wpwg url="' . $URL . '" selector=".price-quote.not_working dd" cache="0" rem_tags="script, style" newtab="false"]'); } // Open the file "zonzoo.csv" for writing $file = fopen('zonzoo.csv', 'w'); // Save the column headers fputcsv($file, array('ID', 'NAME', 'CATEGORY', 'BRAND', 'PRICE', 'DEEPLINK', 'IMAGE', 'SHIPPING')); // Sample data. This can be fetched from MySQL too $data = array ( array(1, 'iPhone 4 16GB', 'Mobiel', 'Apple', 0, 'http://zonzoo.nl/uw-telefoons-verkopen/1023/Apple+iPhone+4+16GB', 'http://www.fonebank.com/images/uploads/handsets/apple-iphone-4-ofic-final.jpg', 0), array(2, 'iPhone 4 32GB', 'Mobiel', 'Apple', 0, 'http://zonzoo.nl/uw-telefoons-verkopen/1024/Apple+iPhone+4+32GB', 'http://www.fonebank.com/images/uploads/handsets/apple-iphone-4-ofic-final.jpg', 0), array(3, 'iPhone 4 8GB', 'Mobiel', 'Apple', 0, 'http://zonzoo.nl/uw-telefoons-verkopen/1272/Apple+iPhone+4+8GB', 'http://www.fonebank.com/images/uploads/handsets/apple-iphone-4-ofic-final.jpg', 0) ); // Replace the prices of working mobile phones $i = 0; foreach ($working as $price_working) { $data[$i][4] = $price_working; $i++; } // Replace the prices of not-working mobile phones $x = 0; foreach ($not_working as $price_not_working) { $data[$x][7] = $price_not_working; $x++; } // Save each row of the data foreach ($data as $row) { fputcsv($file, $row); } // Close the file fclose($file); ?>

preferences:
43.38 ms | 402 KiB | 5 Q