Comparing Arrays in PHP PRO
PHP allows us to compare two arrays using the == and the === operators. The following code sample together with the video clip that follows explain the way each one of these two operators work. <?php //$a = [‘a’=>’avodado’,’b’=>’bamba’,’c’=>’calco’]; //$b = [‘b’=>’bamba’,’a’=>’avodado’,’c’=>’calco’]; $a = [123,455,323]; $b = [323,123,455]; if($a==$b) { echo “a and b equal”; […]
The list Construct in PHP PRO
The list construct in PHP allows us an easy assignment of values that belong to array into variabels in our code. The list construct is highly useful when developing code that works with a relational database. The following code sample shows a simple usage for the list construct. <?php $vec = [2=>”dave”,1=>”ron”,0=>”chen”,3=>”ran”]; list($a,$b,$c) = $vec; […]
The usort Function in PHP PRO
The usort function allows us to specify the criteria by which the array will be sorted. The following code sample includes the definition of the class Student and the creation of an array that its values are references for objects instantiated from Student. Using the usort function we can sort the students according to their […]