DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

How To Use Extract() Function In PHP

01.05.2012
| 4858 views |
  • submit to reddit
        Syntax:   extract(array,extract_rules,prefix)


Sample code:

<?php
$a = 'Original';
$my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse");
extract($my_array);
echo "\$a = $a; \$b = $b; \$c = $c";
?>


OUTPUT:

$a = Cat; $b = Dog; $c = Horse

Credit: <b><a href="http://4dlink.com">4DLink Dir</a></b> and W3Schools.com | <a href="http://web4link.com">Web4link</a>