I have to generate a random string with a fixed length of 10 characters. But the trick is that it must contain at least one lowercase letter, one uppercase one, a digit and one of these symbols: `~!@#$%^&\*()\_-+={}[]|:;"'<>,.?/

I used this simple function before:

```
function generateRandomString($length = 10)
{
    $characters='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_-+={}[]|:;"\'<>,.?/';
    $result = '';
    for ($i = 0; $i < $length; $i++)
        $result .= $characters[rand(0, strlen($characters) - 1)];
    return $result;
}

```

But this function doesn't include at least one of each character type needed. Even if I go another route:

```
function generateRandomString($length = 10)
{
    $dig = '0123456789';
    $low = 'abcdefghijklmnopqrstuvwxyz';
    $upp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $sym = '`~!@#$%^&*()_-+={}[]|:;"\'<>,.?/';
    $result = '';

    for ($i = 0; $i < $length; $i++)
    {
       $foo = rand(1,4);
       switch ($foo)
       {
           case 1:
               $result .= $dig[rand(0, strlen($dig)-1)];
               break;
           case 2:
               $result .= $low[rand(0, strlen($low)-1)];
               break;
           // etc.
       }
        return $result;
    }

```

This still wouldn't necessarily contain at least one of each.
All the characters must be randomly placed. So any help would be much appreciated. Thank you.