Using extract with the EXTR_PREFIX_ALL directive : extract « Data Structure « PHP






Using extract with the EXTR_PREFIX_ALL directive

 
<?php
$Apple="Computer";
$shapes=array('S' => 'Cylinder',
              'N' => 'Rectangle',
              'A' => 'Sphere',
              'O' => 'Sphere',
              'P' => 'Rectangle');

extract($shapes,EXTR_PREFIX_ALL,"shapes");

echo "Apple is $Apple.<br />";
echo "Shapes_Apple is $shapes_Apple";
echo "<br />";
echo "Shapes_NotePad is $shapes_NotePad";
?>
  
  








Related examples in the same category

1.Add the prefix pts to each array key and then make each variable that results into a reference.
2.Extracting Values from Arrays with extract()
3.extract( ) function converts elements into variables
4.extract($points, EXTR_REFS|EXTR_PREFIX_ALL, 'pts');
5.extract($scores, EXTR_PREFIX_ALL, 'score');
6.Using extract on an associative array
7.Using EXTR_PREFIX_ALL on a numeric array