Posts Tagged ‘unset’

How to Remove Item in Array in PHP

Use unset() to remove an item/element in Arrays, see example below

  1. <?PHP
  2.  
  3. $array = array('name'=>'Bill', 'age'=>32, 1=>'25 Main St.',
  4. 2=>'Apt. 24', 'City'=>'San Francisco', 'state'=>'CA');
  5.  
  6. printf("<pre>;%s</ pre>\n", var_export($array, TRUE));
  7.  
  8. unset($array['age']);
  9.  
  10. printf("<pre>%s</ pre>\n", var_export($array, TRUE));
  11.  
  12. ?>

, ,

No Comments



SetPageWidth