Sweeping a bitcoin private key using PHP Is there a PHP script where it validates a bitcoin private key and also gets the public address from the key?

My goal was to:


verify the private key
Get the public address using that private key
Check the balance using an external api
Sweep if balance > 0


I know I can test it by sending some bitcoins to it, or use electrum to attempt the sweep, but let's say I have 100 private keys I need to verify, how would I go about that?
No MVP PHP code, but some bits that could help.


  
  verify the private key
  


Assuming you want a private key to be in the secp256k1 ECDSA range. You could check if the key is any number between 0x1 and  0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140. Take a look in the bitcoin wiki entry to private keys about the key range.


  
  Get the public address using that private key
  


The library BitcoinECDSA.php could help you out here. Especially

$bitcoinECDSA-&gt;setPrivateKey($privateKey);
$bitcoinECDSA-&gt;getAddress(); 



  3 + 4.Check the balance using an external api and sweep if balance > 0


This step can be easily combined. If you want to rely on a third party you could use the Block.io PHP API and Libary. They have an example PHP code for sweeping.