I think you need to use the random function on a cube that "circumscribes" the sphere, and some kind of loop to reject any points from that cube that are not in the sphere.
I don't even know the language so here is some pseudo code.
$result = $sphereR; // just so the loop executes at least once, and to clear the last value of $result
while ($result >= $sphereR)
{
$p = 1 * (rand(<<($sphereX - $sphereR),($sphereY - $sphereR), ($sphereZ - $sphereR)>>, <<($sphereX + $sphereR),($sphereY + $sphereR), ($sphereZ + $sphereR)>>
); // why the 1 * stuff?
$sqrX = pow((
the x value of vector $p - $sphereX), 2);
$sqrY = pow((
the y value of vector $p - $sphereY), 2);
$sqrZ = pow((
the z value of vector $p - $sphereZ), 2);
$result = sqrt($sqrX + $sqrY + $sqrZ);
}