class Solution {
/**
* @param String $ransomNote
* @param String $magazine
* @return Boolean
*/
function canConstruct($ransomNote, $magazine) {
$targets = str_split($ransomNote);
$words = str_split($magazine);
foreach($targets as $target) {
$index = array_search($target, $words);
if ($index === false) {
return false;
}
unset($words[$index]);
}
return true;
}
}