Use of + with arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Stearns

    Use of + with arrays

    In a note on 31-Jul-2002 added to the unshift function the writer
    stated that array2=arrray1+ array2 was equivalent to
    unshift(arrayw, list(array1)). My php seems to take strong objection to
    this [Fatal error: Unsupported operand types in
    /var/www/html/GEM/etFlush/embryo_newFroze n.php on line 417]. Am I doing
    something wrong? Was the original poster on something? Is this a version
    problem?
  • Andy Hassall

    #2
    Re: Use of + with arrays

    On Wed, 06 Jul 2005 15:45:56 -0400, Bob Stearns <rstearns1241@c harter.net>
    wrote:
    [color=blue]
    >In a note on 31-Jul-2002 added to the unshift function the writer
    >stated that array2=arrray1+ array2 was equivalent to
    >unshift(arrayw ,list(array1)). My php seems to take strong objection to
    >this [Fatal error: Unsupported operand types in
    >/var/www/html/GEM/etFlush/embryo_newFroze n.php on line 417].[/color]

    Works for me. Post a minimal test script.
    [color=blue]
    >Am I doing something wrong?[/color]

    Don't know, can't see your code.
    [color=blue]
    >Was the original poster on something?[/color]

    Works for me on 5.0.4.
    [color=blue]
    >Is this a version problem?[/color]

    Don't know, what's your version?

    The following code produces that error:

    <?php
    $arrayone = array("newkey"= >"newvalue") + $arrayone;
    var_dump($array one);
    ?>

    ... because $arrayone is not defined and so isn't an array.

    The following works as required:

    <?php
    $arrayone = array();
    $arrayone = array("newkey"= >"newvalue") + $arrayone;
    var_dump($array one);
    ?>

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    Working...