Pass potentially infinite number of arguments to array except a single numeric variable in a PHP com
- by tehalive
I'm trying to make a PHP script that will take a potentially infinite number of URLs from the command line as arguments. I also need to pass an argument that only has a single numeric value possible (to specify timeout), e.g.:
./urltest.php 60 url1.com url2.com url3.com
I'm not exactly sure how to specify argv[1] to be a single numeric variable while at the same time the rest of the arguments (i.e. the list of urls) go into an array. Maybe something like:
$timeout = $argv[1];
$args = func_get_args();
function numfilter($num) {
return !is_numeric($num);
}
$urls = array_filters($args, 'numfilter');
?
Thanks in advance!