public function shortcodeRandom(Event $event, array $atts, $content, $tag)
    {
        if (strpos($content, ',') === false) {
            return '';
        }

        $elements = explode(',', trim($content));
        $elements = array_map('trim', $elements);
        $c = count($elements);

        if ($c == 2 && is_numeric($elements[0]) && is_numeric($elements[1])) {
            return rand($elements[0], $elements[1]);
        }

        return $elements[array_rand($elements)];
    }
public function shortcodeRandom(Event $event, array $atts, $content, $tag)
    {
        if (strpos($content, ',') === false) {
            return '';
        }

        $elements = explode(',', trim($content));
        $elements = array_map('trim', $elements);
        $c = count($elements);

        if ($c == 2 && is_numeric($elements[0]) && is_numeric($elements[1])) {
            return rand($elements[0], $elements[1]);
        }

        return $elements[array_rand($elements)];
    }
public function shortcodeRandom ( Event $ event , array $ atts , $ content , $ tag ) { if ( strpos ( $ content , ',' ) === false ) { return '' ; } $ elements = explode ( ',' , trim ( $ content ) ) ; $ elements = array_map ( 'trim' , $ elements ) ; $ c = count ( $ elements ) ; if ( $ c == 2 && is_numeric ( $ elements [ 0 ] ) && is_numeric ( $ elements [ 1 ] ) ) { return rand ( $ elements [ 0 ] , $ elements [ 1 ] ) ; } return $ elements [ array_rand ( $ elements ) ] ; }
Implements the "random" shortcode.

{random}1,2,3{/random}

@param \Cake\Event\Event $event The event that was fired
@param array $atts An associative array of attributes, or an empty string if
no attributes are given
@param string $content The enclosed content (if the shortcode is used in its
enclosing form)
@param string $tag The shortcode tag
@return string
Implements the random shortcode .