Phraw Official Forum

The discussions here are for Phraw, a micro framework for the PHP programming language.

Return to the Phraw home.

You are not logged in.


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/davmuz/public_html/phraw/forum/include/parser.php on line 840

#1 2012-03-02 15:52:50

davmuz
Admin
From: Maranello, Italy
Registered: 2011-08-18
Posts: 23
Website

New shorter syntax for the arrays with PHP 5.4

Finally PHP have a short syntax for make arrays!

This is an example for the tree routing with PHP 5.3 and before:

<?php
//...
$tree_pages = array(
    '' => array(null, 'index.html'),
    'about/' => array(null, 'about.html'),
    'contacts/' => array(null, 'contacts.html'),
    'documentation/' => array(
        array(
            '' => array(null, 'documentation/index.html'),
            'setup/' => array(null, 'setup.html'),
            'guide/' => array(null, 'guide.html'),
            'reference/' => array(null, 'reference.html'),
            'faq/' => array(null, 'faq.html'),
        )
    )
);
//...
?>

This is the same code with PHP 5.4 and the new short syntax, much easier to read:

<?php
//...
$tree_pages = [
    '' => [null, 'index.html'],
    'about/' => [null, 'about.html'],
    'contacts/' => [null, 'contacts.html'],
    'documentation/' => [[
        '' => [null, 'documentation/index.html'],
        'setup/' => [null, 'setup.html'],
        'guide/' => [null, 'guide.html'],
        'reference/' => [null, 'reference.html'],
        'faq/' => [null, 'faq.html'],
    ]]
];
//...
?>

Offline

Board footer

Powered by FluxBB