检查是否可以使用PHP从随机字母字符串创建单词

<?php
    $randomstring = 'raabccdegep';
    $arraylist = array("car", "egg", "total");
?>

Above $randomstring is a string which contain some alphabet letters. And I Have an Array called $arraylist which Contain 3 Words Such as 'car' , 'egg' , 'total'.

Now I need to check the string Using the words in array and print if the word can be created using the string. For Example I need an Output Like.

car is possible.
egg is not possible.
total is not possible.

Also Please Check the repetition of letter. ie, beep is also possible. Because the string contains two e. But egg is not possible because there is only one g.

function find_in( $haystack, $item ) {
    $match = '';
    foreach( str_split( $item ) as $char ) {
        if ( strpos( $haystack, $char ) !== false ) {
            $haystack = substr_replace( $haystack, '', strpos( $haystack, $char ), 1 );
            $match .= $char;
        }
    }
    return $match === $item;
}

$randomstring = 'raabccdegep';
$arraylist = array( "beep", "car", "egg", "total");

foreach ( $arraylist as $item ) {
    echo find_in( $randomstring, $item ) ? " $item found in $randomstring." : " $item not found in $randomstring.";
}
This should do the trick:
<?php
$randomstring = 'raabccdegep';
$arraylist = array("car", "egg", "total");

foreach($arraylist as $word){
    $checkstring = $randomstring;
    $beMade = true;
    for( $i = 0; $i < strlen($word); $i++ ) {
        $char = substr( $word, $i, 1 );
        $pos = strpos($checkstring, $char);
        if($pos === false){
            $beMade = false;
        } else {
            substr_replace($checkstring, '', $i, 1);    
        }
    }
    if ($beMade){
        echo $word . " is possible 
";
    } else {
        echo $word . " is not possible 
";
    }
}
?>