From:             deadkrolik at gmail dot com
Operating system: any
PHP version:      6CVS-2007-05-20 (CVS)
PHP Bug Type:     Feature/Change Request
Bug description:  New operator feature request

Description:
------------
It's not a bug, it's a new language operator suggestion. When I use other
languages and PHP it's often were a one task - return values from function.
I suggest a new operator and a don't know any analogs in other languages
(may be I now small count of languages).

Reproduce code:
---------------
Task - return values from function with accumulating of results. For
example, when we read strings from file and want return array of this
strings (may be modified) from function we must accumulate/collect all
values in array or in string:

function read_array($in) {

    $out = array();

    foreach(file($in) as $str) {

        $str = trim($str);
  
        //some modifications

        $out[] = $str;
        //OR $all_str .= $str
    }

    return $out;
    //OR return $all_str
}

It's a very often task. And may be it's will be useful for programers have
two new operators - for strings and for arrays, that accumulate values
within all function body and at the end return ALL strings/elements
automatically.

For example:

function read_array($in) {

    foreach(file($in) as $str) {

        $str = trim($str);
  
        //some actions

        return_array $str;//accumulate $str to internal temporary array,
that will be returned at the end of function
    }
}

And "return_string" for strings temporary buffer.

-- 
Sorry for my terible English. With best regards Dead Krolik.


-- 
Edit bug report at http://bugs.php.net/?id=41450&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41450&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41450&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41450&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41450&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41450&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41450&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41450&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41450&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41450&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41450&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41450&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41450&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41450&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41450&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41450&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41450&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41450&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41450&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41450&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41450&r=mysqlcfg

Reply via email to