Sample code for 30+ languages & platforms
PHP ActiveX

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

$pkey = new COM("Chilkat.PrivateKey");

// Load the private key from an PEM file:
$success = $pkey->LoadPemFile('private.pem');
if ($success == 0) {
    print $pkey->LastErrorText . "\n";
    exit;
}

$pubKey = new COM("Chilkat.PublicKey");
$pkey->ToPublicKey($pubKey);

$success = $pubKey->SavePemFile(0,'pubKey.pem');
if ($success != 1) {
    print $pubKey->LastErrorText . "\n";

    exit;
}

print 'Success.' . "\n";

?>