PHP compact() functionThe compact( ) function is an inbuilt function of PHP, and it is used to create an array from variables and their values. This function was introduced in PHP 4+. SyntaxParameters
Return ValuesThis function returns an array with all the variables added to it. Important noteAny strings that do not match variables names will be skipped. Example 1Output: Array ( [sachin] => 18426 [ganguly] => 11363 [virat] => 9779 ) Example 2Output: Array ( [firstname] =>java [lastname] =>tpoint [location] =>noida ) Example 3Output: Array ( [KR] => KERELA [FL] => FLOOD [HL] => 600cr ) Example 4Output: Array ( [firstname] =>sachin [lastname] =>tendulkar [age] => 45 )
Next TopicPHP Array Functions
|