PHP Parallel curl requests

If you mean multi-curl then, something like this might help: $nodes = array($url1, $url2, $url3); $node_count = count($nodes); $curl_arr = array(); $master = curl_multi_init(); for($i = 0; $i < $node_count; $i++) { $url =$nodes[$i]; $curl_arr[$i] = curl_init($url); curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true); curl_multi_add_handle($master, $curl_arr[$i]); } do { curl_multi_exec($master,$running); } while($running > 0); for($i = 0; $i < … Read more

JavaScript equivalent of PHP’s in_array()

No, it doesn’t have one. For this reason most popular libraries come with one in their utility packages. Check out jQuery’s inArray and Prototype’s Array.indexOf for examples. jQuery’s implementation of it is as simple as you might expect: function inArray(needle, haystack) { var length = haystack.length; for(var i = 0; i < length; i++) { … Read more

Listing all the folders subfolders and files in a directory using php

function listFolderFiles($dir){ $ffs = scandir($dir); unset($ffs[array_search(‘.’, $ffs, true)]); unset($ffs[array_search(‘..’, $ffs, true)]); // prevent empty ordered elements if (count($ffs) < 1) return; echo ‘<ol>’; foreach($ffs as $ff){ echo ‘<li>’.$ff; if(is_dir($dir.”https://stackoverflow.com/”.$ff)) listFolderFiles($dir.”https://stackoverflow.com/”.$ff); echo ‘</li>’; } echo ‘</ol>’; } listFolderFiles(‘Main Dir’);