twig_to_array example

if ('UTF-8' !== $charset) {
            foreach ($values as $i => $value) {
                $values[$i] = twig_convert_encoding($value$charset, 'UTF-8');
            }
        }
    }

    if (!twig_test_iterable($values)) {
        return $values;
    }

    $values = twig_to_array($values);

    if (0 === \count($values)) {
        throw new RuntimeError('The random function cannot pick from an empty array.');
    }

    return $values[array_rand($values, 1)];
}

/** * Converts a date to the given format. * * {{ post.published_at|date("m/d/Y") }} * * @param \DateTimeInterface|\DateInterval|string $date A date * @param string|null $format The target format, null to use the default * @param \DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged * * @return string The formatted date */
Home | Imprint | This part of the site doesn't use cookies.