compact

array compact(mixed varname, [mixed ...]) 

Creates an array containing variables from the current scope.

Returns:

Associative array

Description:

This function performs the opposite job of extract(). Given one or more variable names, it places each named variable into an associative array, with the key of each element being the name of a variable from the current scope and the value of each element being the value of that variable. The array thus constructed is then returned.

Each parameter can be either a string giving the name of a variable to place into the array, or an array of variable names. Arrays can be nested as deeply as you like; compact() recurses over them.

Variables are skipped if they are not set within the scope in which ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.