note 19557 deleted from functions.returning-values by aharvey

From: Date: Wed, 05 Sep 2012 02:14:07 +0000
Subject: note 19557 deleted from functions.returning-values by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190505@lists.php.net to get a copy of this message
Note Submitter: destes at ix dot netcom dot com dot nospam ---- One thing to note about returning arrays- the usual "complex variable" syntax will give you a parse error. For instance, if you have: function adminstuff() { mysql_connect('localhost', 'user', 'pass'); mysql_select_db('mydb'); $result = mysql_query('SELECT login, pass FROM users); $resultrow = mysql_fetch_array( $result ); # this next line is key: return array ({$resultrow['login']}, {$resultrow['pass']}); } That won't work. You *can* reference array elements without the curly-braces syntax, i.e.: return array ($resultrow['login'], $resultrow['pass']); But you'll get a parse error if you try to use curly braces. Thanks, Steve

« previous php.notes (#190505) next »