Sometime we may need to use the same variable name that you are using in the query or simply in an associative array.
Lets say you have an associative array :
$arr = array( 'totalLimit' => 50, 'limit' => 10 );
The usually what we do is to find the array element by their indexes.
i.e.,
$totalLimit = $arr['totalLimit'];
echo $totalLimit;
You have a better way of doing the same thing in php i.e.
$arr = array( 'totalLimit' => 50, 'limit' => 10 );
extract($arr);
now you can directly use the keys as the variable name:
echo $totalLimit;
echo $limit;
O/P: 50 10
Definition and Usage
The extract() function imports variables into the local symbol table from an array.
This function uses array keys as variable names and values as variable values. For each element it will
create a variable in the current symbol table.This function returns the number of variables
extracted on success. - By W3SCHOOLS
0 Comment(s)