Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Return Multiple Values From A Function in PHP
#1

function can not return multiple values, but similar results can be obtained by returning an array. Solution is very simple and straight forward.
PHP Code:
<?php
 function returnMultipleValues
(){
 $result = array() ;

 $result['first'] = "multiple value 1" ;
 $result['second']= "multiple value 2" ;
 return $result ; 
}

$thisIsMultiple = returnMultipleValues() ;
echo $thisIsMultiple['first'] ."<br>" ;
echo $thisIsMultiple['second'] ."<br>" ;

?>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)