Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace_array_callback() #19

Open
KarelWintersky opened this issue Sep 18, 2024 · 0 comments
Open

replace_array_callback() #19

KarelWintersky opened this issue Sep 18, 2024 · 0 comments

Comments

@KarelWintersky
Copy link
Collaborator

    /**
     * Выполняет explode строки роута с учетом дефолтной маски
     * Заменяет list($a, $b) = explode(separator, string) с дефолтными значениями элементов
     * Хотел назвать это replace_array_callback(), но передумал
     *
     * @param $income
     * @param array $default
     * @param string $separator
     * @return array
     */
    function replace_array_callback(array $income = [], array $default = []): array
    {
        return \array_map(static function($first, $second) {
            return empty($second) ? $first : $second;
        }, $default, income);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant