Werte in Array tauschen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Werte in Array tauschen

    Hallo Leute,

    ich habe ein Array: $farbliste und ein Array: $farbe
    PHP Code:
    <?php  $farbliste = array(1=>rot2=>gelb3=>blau4=>schwarz5=>weiss);    
    $farbe = array(241);  ?>
    nun möchte ich ein Ergebnis-Array in dem nicht die Zahlen sondern die Werte stehen.

    Das Ergebnis-Array soll dann so aussehen:

    PHP Code:
    $farben = array(gelbschwarzrot); 
    Gruß Conny

  • #2
    hast du doch schon. nutze jetzt noch die werte des ersten arrays als schlüssel der $farbliste. wo ist das problem?

    Comment


    • #3
      Hat sich erledigt

      foreach ($farbe as $key => $farbid) $farben[$key] = $farbliste[$farbid];

      Comment


      • #4
        Wei wärs mit
        PHP Code:
        $farbe = array(241);
        $farben = array();
        $farbliste = array(1=>rot2=>gelb3=>blau4=>schwarz5=>weiss);
        foreach(
        $farbe as $wert){
            
        $farben[] = $farbliste[$wert];

        Gruss

        tobi
        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

        Comment


        • #5
          Danke für die schnelle Hilfe.

          Comment

          Working...
          X