How does a php function return multiple values? This article mainly introduces the implementation of functions in PHP that can return multiple values, and analyzes the techniques of PHP using arrays to return multiple values. I hope to be helpful.
In python and golang, there is a method for a function to return multiple values at the same time. In fact, php can also do it, but it is a little more troublesome than python and golang. The following is A simple demonstration example, the list function is used here
<?php function retrieve_user_profile() { $user[] = "Jason"; $user[] = "php.cn"; $user[] = "English"; return $user; } list($name,$email,$language) = retrieve_user_profile(); echo "Name: $name, email: $email, preferred language: $language"; ?>
Related recommendations:
Introduction to PHP function syntax 1_PHP tutorial
Simple summary of PHP function learning _PHP Tutorial
The above is the detailed content of php function returns instance of multiple values. For more information, please follow other related articles on the PHP Chinese website!