note 19557 added to functions.returning-values

From: Date: Sun, 03 Mar 2002 17:35:36 +0000
Subject: note 19557 added to functions.returning-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-27297@lists.php.net to get a copy of this message
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 -- http://www.php.net/manual/en/functions.returning-values.php http://master.php.net/manage/user-notes.php?action=edit+19557 http://master.php.net/manage/user-notes.php?action=delete+19557 http://master.php.net/manage/user-notes.php?action=reject+19557

« previous php.notes (#27297) next »