Learning PHP and MySQL

Example 06-10 Using extract with the EXTR_PREFIX_ALL directive

<?php
$Apple
="Computer";
$shapes=array('SodaCan'  =>  'Cylinder',
              
'NotePad'  =>  'Rectangle',
              
'Apple'  =>  'Sphere',
              
'Orange'  =>  'Sphere',
              
'PhoneBook'  =>  'Rectangle');

extract($shapes,EXTR_PREFIX_ALL,"shapes");
//  $shapes_SodaCan,  $shapes_NotePad,  $shapes_Apple,  $shapes_Orange,  and
//$shapes_PhoneBook  are  now  set

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

Posted by on 08/07 at 10:25 AM

Next entry: Example 06-11 Using EXTR_PREFIX_ALL on a numeric array

Previous entry: Example 06-09 Using extract on an associative array

<< Back to main