dougou1943 2010-08-03 10:34
浏览 6
已采纳

数组替换功能对我不起作用

is there any array replace function in php ..

in php manual there is a function called array_replace but its not working...

Tell me some example...

for array replace..

  • 写回答

3条回答 默认 最新

  • dongwuwu6104 2010-08-03 10:43
    关注
    <?php
    $base = array("orange", "banana", "apple", "raspberry");
    $replacements = array(0 => "pineapple", 4 => "cherry");
    $replacements2 = array(0 => "grape");
    
    $basket = array_replace($base, $replacements, $replacements2);
    echo '<pre>' .
    print_r($base, true) .
    print_r($basket, true) .
    '</pre>';
    

    output

    Array
    (
        [0] => orange
        [1] => banana
        [2] => apple
        [3] => raspberry
    )
    Array
    (
        [0] => grape
        [1] => banana
        [2] => apple
        [3] => raspberry
        [4] => cherry
    )
    

    the question is: what exactly isnt working for you?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?