Working with Array[ ]

Array in PHP

$arrdata = $array(

     '1'=>'foo',
     '2'=>'bar',
     '3'=>'baz');
$arrval = array_values($arrdata); // gives ['foo','bar','baz']
$arrkey = array_keys($arrdata); // gives ['1','2','3']

$array_push($arrval,'bat'); // insert 'bat'
$array_pop($arrval,'bat');  // remove 'bat'

$a = $arraydata['1'];



Compare and check if two array conatins are identical

array1 = ['a', 'b','c'];
array2 = ['a1', 'b2' , 'c3' ];
if( array1.toString() == array2.toString() ){
         //identical
}else{
     // non identical
}

Share this

Related Posts

Previous
Next Post »