Arrays Short Syntax in PHP 5.4 PRO

As of PHP 5.4 we can create new arrays in a simple way. Simpler than ever. The following code sample shows that.

<?php
$vec_a = [4,6,2,7];
$vec_b = ['a'=>'australia','b'=>'belgium','c'=>'canada'];
foreach($vec_a as $k=>$v)
{
    echo " ".$k."=>".$v;
}
foreach($vec_b as $k=>$v)
{
    echo " ".$k."=>".$v;
}
?>

The following video clip shows the execution of this code sample and explains it.

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences