There's nothing dodgy about my code I can assure you. The house does have an advantage because you go first and if you go bust the house wins without ever having to hit. It's as simple as that. This is no different than playing in a casino.
Hell you could stick on whatever 2 cards you get to start with and there is probably a reasonable chance the dealer will bust because they'll just keep going until they have at least 17. The dealer doesn't have the luxury of being able to stand at a lower value, you do. It all comes down to the luck of the draw. If you play long enough the house will invariably win in the end, this too is no different than a casino and that is why they do everything they can to keep you there for as long as possible.
Hell I'll even share my card generation function with you. Feel free to test it for yourself and you'll see it generates a random result:
echo get_shuffled_cards();
function get_shuffled_cards()
{
$cards=array("2c","3c","4c","5c","6c","7c","8c","9c","tc","jc","qc","kc","ac","2d","3d","4d","5d","6d","7d","8d","9d","td","jd","qd","kd","ad","2h","3h","4h","5h","6h","7h","8h","9h","th","jh","qh","kh","ah","2s","3s","4s","5s","6s","7s","8s","9s","ts","js","qs","ks","as");
shuffle($cards);
$shuffled_cards="";
foreach($cards as $v)
{
$shuffled_cards.=$v.",";
}
return trim($shuffled_cards, ",");
}
?>