On 11-07-05 09:40 AM, Dajka Tamas wrote:

foreach ( $cats as&$c ) {

                echo $c['id'];

                if ( $c['id']<  5 ) {

                               $c['id']++;

                               $cats[] = $c;

                }

}

Given that you seem to want the above functionality obtained when more than one element exists in the input array... the simplest way (I can bother to think up) to achieve what you want with little extra work is to do the following:

<?php

$cats['_control_'] = null;
foreach ( $cats as &$c )
{
    if( $c === null )
    {
        continue;
    }

    echo $c['id'];

    if ( $c['id'] < 5 )
    {
        $c['id']++;
        $cats[] = $c;
    }
}
unset( $cats['_control_'] );

?>

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to