Retrieve data from multiple WordPress sites using PHP script

Write a bash script (or any other shell script) to loop ocer the site and in php just write the detection for a single site and output the value to standard output or a file.

Or use http://wp-cli.org/ (which essentially does for you the php code from the paragraph above).