Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.www.php > #19989

sostituire solo gli elementi esistenti in un array

From alex <1j9448a02@lnx159sneakemail.com.invalid>
Newsgroups it.comp.www.php
Subject sostituire solo gli elementi esistenti in un array
Date 2015-10-10 14:38 +0200
Organization Aioe.org NNTP Server
Message-ID <mvb0sp$7tg$1@speranza.aioe.org> (permalink)

Show all headers | View raw


$base = array("orange");
$replacements = array(0 => "pineapple", 4 => "cherry");

$basket = array_replace($base, $replacements);
print_r($basket);


Il problema è che viene inserito anche l'elemento 4.
Io invece vorrei che venissero rimpiazzati solo gli elementi già 
esistenti nell'array $base (tutto il resto deve essere scartato).

In pratica invece di

Array (
   [0] => pineapple
   [4] => cherry
)

voglio ottenere solo

Array (
   [0] => pineapple
)

Si può?

Back to it.comp.www.php | Previous | NextNext in thread | Find similar | Unroll thread


Thread

sostituire solo gli elementi esistenti in un array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2015-10-10 14:38 +0200
  Re: sostituire solo gli elementi esistenti in un array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2015-10-10 16:15 +0200
    Re: sostituire solo gli elementi esistenti in un array fmigliori <fmigliori@gmail.com> - 2015-10-10 23:56 -0700
      Re: sostituire solo gli elementi esistenti in un array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2015-10-11 11:13 +0200
        Re: sostituire solo gli elementi esistenti in un array fmigliori <fmigliori@gmail.com> - 2015-10-11 03:37 -0700
        Re: sostituire solo gli elementi esistenti in un array Leonardo Serni <lserni@gmail.com> - 2015-10-11 13:26 +0200
          Re: sostituire solo gli elementi esistenti in un array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2015-10-12 20:27 +0200
  Re: sostituire solo gli elementi esistenti in un array Leonardo Serni <lserni@gmail.com> - 2015-10-11 13:19 +0200
    Re: sostituire solo gli elementi esistenti in un array Leonardo Serni <lserni@gmail.com> - 2015-10-11 13:23 +0200
      Re: sostituire solo gli elementi esistenti in un array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2015-10-12 20:36 +0200

csiph-web