> For the complete documentation index, see [llms.txt](https://algorithm.national-cat.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algorithm.national-cat.me/leetcode/383.-ransom-note.md).

# 383. Ransom Note

```php
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;
    }
}
```
