Last active
March 13, 2021 18:31
-
-
Save BackEndTea/c1da0db8f447f79567bd2894f469af04 to your computer and use it in GitHub Desktop.
array of strings to int
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @param array<string> $in | |
| * | |
| * @return array<int> | |
| */ | |
| function withIntval(array $in): array | |
| { | |
| return array_map('intval', $in); | |
| } | |
| /** | |
| * @param array<string> $in | |
| * | |
| * @return array<int> | |
| */ | |
| function withCast(array $in): array | |
| { | |
| return array_map(fn(string $val): int => (int) $val, $in); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment