is_iterable

Supported Versions: PHP 7 >= 7.1.0, PHP 8
Verify that the contents of a variable is an iterable value
<?php is_iterable(mixed $value): bool
<?php     public function add($jobs)

    {

        $jobs = is_iterable($jobs) ? $jobs : Arr::wrap($jobs);



        foreach ($jobs as $job) {

            $this->jobs->push($job);
<?php             if ($segment === '*') {

                if ($target instanceof Collection) {

                    $target = $target->all();

                } elseif (! is_iterable($target)) {

                    return value($default);

                }
<?php     public function withProgressBar($totalSteps, Closure $callback)

    {

        $bar = $this->output->createProgressBar(

            is_iterable($totalSteps) ? count($totalSteps) : $totalSteps

        );



        $bar->start();
<?php         $bar->start();



        if (is_iterable($totalSteps)) {

            foreach ($totalSteps as $value) {

                $callback($value, $bar);
<?php         $bar->finish();



        if (is_iterable($totalSteps)) {

            return $totalSteps;

        }

    }
<?php     protected function trailingNewLineCount($messages)

    {

        if (is_iterable($messages)) {

            $string = '';



            foreach ($messages as $message) {
<?php         foreach ($mutators as $mutator) {

            $mutator = new $mutator;



            if (is_iterable($data)) {

                foreach ($data as $key => $value) {

                    $data[$key] = $mutator($value);

                }
<?php     protected function arrayOfAddresses($address)

    {

        return is_iterable($address) || $address instanceof Arrayable;

    }
<?php     {

        $command = $command ?? $this->command;



        $process = is_iterable($command)

                ? new Process($command, null, $this->environment)

                : Process::fromShellCommandline((string) $command, null, $this->environment);
<?php             $haystack = mb_strtolower($haystack);

        }



        if (! is_iterable($needles)) {

            $needles = (array) $needles;

        }
<?php     public static function endsWith($haystack, $needles)

    {

        if (! is_iterable($needles)) {

            $needles = (array) $needles;

        }
<?php     {

        $value = (string) $value;



        if (! is_iterable($pattern)) {

            $pattern = [$pattern];

        }
<?php     {

        $value = (string) $value;



        if (! is_iterable($pattern)) {

            $pattern = [$pattern];

        }
<?php     public static function startsWith($haystack, $needles)

    {

        if (! is_iterable($needles)) {

            $needles = [$needles];

        }
<?php             return call_user_func($this->echoHandlers[get_class($value)], $value);

        }



        if (is_iterable($value) && isset($this->echoHandlers['iterable'])) {

            return call_user_func($this->echoHandlers['iterable'], $value);

        }