array_pad

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Pad array to the specified length with a value
<?php array_pad(array $array, int $length, mixed $value): array
<?php     public function pad($size, $value)

    {

        return new static(array_pad($this->items, $size, $value));

    }
<?php     protected function parseSchemaAndTable($reference)

    {

        $parts = array_pad(explode('.', $reference, 2), -2, null);



        if (str_contains($parts[1], '.')) {

            $database = $parts[0];
<?php     protected function parseMiddleware($middleware)

    {

        [$name, $parameters] = array_pad(explode(':', $middleware, 2), 2, []);



        if (is_string($parameters)) {

            $parameters = explode(',', $parameters);
<?php     protected function parsePipeString($pipe)

    {

        [$name, $parameters] = array_pad(explode(':', $pipe, 2), 2, []);



        if (is_string($parameters)) {

            $parameters = explode(',', $parameters);
<?php     protected function parseQueues($queues)

    {

        return collect(explode(',', $queues))->map(function ($queue) {

            [$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null);



            if (! isset($queue)) {

                $queue = $connection;
<?php         [$name, $parameters] = array_pad(explode(':', $name, 2), 2, null);



        return ($map[$name] ?? $name).(! is_null($parameters) ? ':'.$parameters : '');

    }
<?php                 continue;

            }



            [$middleware, $parameters] = array_pad(

                explode(':', $middleware, 2), 2, null

            );
<?php     public function parseNamedParameters($parameters)

    {

        return array_reduce($parameters, function ($result, $item) {

            [$key, $value] = array_pad(explode('=', $item, 2), 2, null);



            $result[$key] = $value;
<?php         $uri = Str::removeLeft($uri, '/');



        [$taxonomy, $slug] = array_pad(explode('/', $uri), 2, null);



        if (! $slug) {

            return null;
<?php             return $key === 'taxonomy' || Str::startsWith($key, 'taxonomy:');

        })->each(function ($values, $param) use ($query) {

            $taxonomy = substr($param, 9);

            [$taxonomy, $modifier] = array_pad(explode(':', $taxonomy), 2, 'any');



            if (is_string($values)) {

                $values = array_filter(explode('|', $values));
<?php {

    public function validate($attribute, $value, $parameters, $validator)

    {

        [$collection, $except, $site] = array_pad($parameters, 3, null);



        $query = Entry::query();
<?php {

    public function validate($attribute, $value, $parameters, $validator)

    {

        [$taxonomy, $except, $site] = array_pad($parameters, 3, null);



        $query = Term::query();
<?php {

    public function validate($attribute, $value, $parameters, $validator)

    {

        [$except] = array_pad($parameters, 1, null);



        $existing = User::query()

            ->where($attribute, $value)
<?php         ));




        list($needle, $textConstraint) = array_pad(

            explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),

            2,

            $input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*'

        );




        $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
<?php     private function extractTokens(string $statement, int $limit = -1)

    {

        return array_pad(preg_split('/[ \t]+/', $statement, $limit), $limit, null);

    }



    private function analyzeQuery($statement)