php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #6950 make extract() return true or false
Submitted: 2000-09-29 19:59 UTC Modified: 2001-01-23 11:41 UTC
From: rwidmer at developersdesk dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.2 OS: Linux (SUSE 6.3)
Private report: No CVE-ID: None
 [2000-09-29 19:59 UTC] rwidmer at developersdesk dot com
Please make extract() return true if there was an array to process, or false if the value of the 'array' parameter was not an array  This change will  simplify iterating a database,  and may be usefile elsewhere.


After the following query:

   $Result = mysql_query( "SELECT Field1, Field2, Field3 FROM Table" );


you will be able to display the conents of the table with:

   while( extract( mysql_fetch_array( $Result )) {
      echo $Field1, $Field2, $Field3;
      }


rather than:

   while( $A = mysql_fetch_array( $Result )) {
      extract( $A );
      echo $Field1, $Field2, $Field3;
      }


This change should not affect backwards compatability, as existing users of extract() don't expect any return value.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-23 11:41 UTC] cynic@php.net
extract() was recently changed to return the number of extracted variables, so I guess this can be closed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 26 22:01:27 2024 UTC