extract($points, EXTR_REFS|EXTR_PREFIX_ALL, 'pts'); : extract « Data Structure « PHP






extract($points, EXTR_REFS|EXTR_PREFIX_ALL, 'pts');

 
<?php

  $points = array('home' => 21, 'away' => 13);

  extract($points, EXTR_REFS|EXTR_PREFIX_ALL, 'pts');

  $pts_home -= 4;
  $pts_away += 6;

  printf("<pre>%s</pre>", var_export($points, TRUE));
?>
  
  








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($scores, EXTR_PREFIX_ALL, 'score');
5.Using extract on an associative array
6.Using extract with the EXTR_PREFIX_ALL directive
7.Using EXTR_PREFIX_ALL on a numeric array