Ergebnis 1 bis 10 von 10

Thema: foreach-Schleife; eigenartiges Problem

  1. #1
    Teeny
    Registriert seit
    06.01.2014
    Beiträge
    27
    Danke
    1
    Bekam 1 mal "Danke" in 1 Posting

    Standard foreach-Schleife; eigenartiges Problem

    Hallo liebe Foren-Community!

    Ich habe ein Problem mit einer Foreach-Schleife das so strange ist dass ich garnicht weiss wie ich es umschreiben soll

    Ich baue grade eine Farbpalette zusammen. Die Farbwerte stehen in einem Array, das dann in der Schleife zu brauchbaren HTML gemacht wird.

    In der Schleife lass ich noch einen Counter mitlaufen um Zeilennummern zu vergeben.

    Jetzt das Problem: Die Zeilennummern sollen nur am weißen und schwarzen Rand stehen, das klappt soweit auch. Aber bei 4 Feldern erscheint die Zeilennummer wo sie nicht hingehört. Siehe Bild:


    PHP gibt keine Fehler aus (E_ALL) und die Werte im Array sind an den betreffenden Stellen richtig eingetragen.
    Ich komm nicht drauf was das sein könnte. Hier noch der Code:
    PHP-Code:
    $count 1;
    foreach(
    $farben as $arr){
        foreach(
    $arr as $value){
            if(
    $value == 'FFFFFF' OR $value == '000000'){$text $count;}
            else{
    $text ' ';}
            
            if(
    $value == '000000'){$color ' color:#FFFFFF;';}
            else{
    $color '';}
            
            
    $preoutput .= '<div style="background-color:#'.$value.';'.$color.'" title="'.$value.'">'.$text.'</div>'."\n";
        }

        
    $output .= '<div class="row">'."\n".$preoutput."\n".'</div><div class="clear">&nbsp;</div>'."\n";
        
        
    $preoutput '';
        
    $count++;

    Es handelt sich um die Farben #00E600, #00E617, #00E645, #00E673, fals das von Bedeutung ist.


    Ich bedanke mich schon mal für eure Mühe

    Grüße
    Achtung: Dies ist ein alter Thread im HTML und Webmaster Forum
    Diese Diskussion ist älter als 90 Tage. Die darin enthaltenen Informationen sind möglicherweise nicht mehr aktuell. Erstelle bitte zu deiner Frage ein neues Thema im Forum !!!!!

  2. #2
    Bandit
    Gast

    Standard AW: foreach-Schleife; eigenartiges Problem

    Es wäre gut, wenn du das komplette Script, also auch die Arrays posten würdest, um das mal zu testen

  3. #3
    Teeny
    Themenstarter

    Registriert seit
    06.01.2014
    Beiträge
    27
    Danke
    1
    Bekam 1 mal "Danke" in 1 Posting

    Standard AW: foreach-Schleife; eigenartiges Problem

    Das Script bzw. die Palette ist noch nicht ganz fertig (es fehlen noch Farben) und da es noch in der Entwicklung ist sieht es wohl noch ziemlich chaotisch aus (css nicht ausgelagert usw.)

    PHP-Code:
    <?php
    error_reporting
    (E_ALL);

    // Rot
    $farben[]  = array('FFFFFF''FFF2F2''FFE6E6''FFD9D9''FFCCCC''FFBFBF',  'FFB3B3''FFA6A6''FF9999''FF8C8C''FF8080''FF7373''FF6666',  'FF5959''FF4D4D''FF4040''FF3333''FF2626''FF1A1A''FF0D0D',  'FF0000''F20000''E60000''D90000''CC0000''BF0000''B30000',  'A60000''990000''8C0000''800000''730000''660000''590000',  '4D0000''400000''330000''260000''1A0000''0D0000''000000');
    $farben[]  = array('FFFFFF''FFF3F2''FFE7E6''FFDBD9''FFCFCC''FFC3BF',  'FFB6B3''FFAAA6''FF9E99''FF928C''FF8680''FF7A73''FF6E66',  'FF6259''FF564D''FF4A40''FF3D33''FF3126''FF251A''FF190D',  'FF0D00''F20C00''E60C00''D90B00''CC0A00''BF0A00''B30900',  'A60800''990800''8C0700''800700''730600''660500''590500',  '4D0400''400300''330300''260200''1A0100''0D0100''000000');
    $farben[]  = array('FFFFFF''FFF4F2''FFE8E6''FFDDD9''FFD1CC''FFC6BF',  'FFBAB3''FFAFA6''FFA399''FF988C''FF8D80''FF8173''FF7666',  'FF6A59''FF5F4D''FF5340''FF4833''FF3C26''FF311A''FF250D',  'FF1A00''F21900''E61700''D91600''CC1500''BF1400''B31200',  'A61100''991000''8C0E00''800D00''730C00''660A00''590900',  '4D0800''400700''330500''260400''1A0300''0D0100''000000');
    $farben[]  = array('FFFFFF''FFF4F2''FFE9E6''FFDED9''FFD4CC''FFC9BF',  'FFBEB3''FFB3A6''FFA899''FF9D8C''FF9380''FF8873''FF7D66',  'FF7259''FF674D''FF5C40''FF5133''FF4726''FF3C1A''FF310D',  'FF2600''F22400''E62200''D92000''CC1E00''BF1D00''B31B00',  'A61900''991700''8C1500''801300''731100''660F00''590D00',  '4D0B00''400A00''330800''260600''1A0400''0D0200''000000');
    $farben[]  = array('FFFFFF''FFF5F2''FFEBE6''FFE0D9''FFD6CC''FFCCBF',  'FFC2B3''FFB8A6''FFAD99''FFA38C''FF9980''FF8F73''FF8566',  'FF7A59''FF704D''FF6640''FF5C33''FF5226''FF471A''FF3D0D',  'FF3300''F23000''E62E00''D92B00''CC2900''BF2600''B32400',  'A62100''991F00''8C1C00''801A00''731700''661400''591200',  '4D0F00''400D00''330A00''260800''1A0500''0D0300''000000');
    $farben[]  = array('FFFFFF''FFF5F2''FFECE6''FFE2D9''FFD9CC''FFCFBF',  'FFC6B3''FFBCA6''FFB399''FFA98C''FFA080''FF9673''FF8C66',  'FF8359''FF794D''FF7040''FF6633''FF5D26''FF531A''FF4A0D',  'FF4000''F23D00''E63A00''D93600''CC3300''BF3000''B32D00',  'A62A00''992600''8C2300''802000''731D00''661A00''591600',  '4D1300''401000''330D00''260A00''1A0600''0D0300''000000');
    $farben[]  = array('FFFFFF''FFF6F2''FFEDE6''FFE4D9''FFDBCC''FFD3BF',  'FFCAB3''FFC1A6''FFB899''FFAF8C''FFA680''FF9D73''FF9466',  'FF8B59''FF824D''FF7A40''FF7133''FF6826''FF5F1A''FF560D',  'FF4D00''F24900''E64500''D94100''CC3E00''BF3A00''B33600',  'A63200''992E00''8C2A00''802700''732300''661F00''591B00',  '4D1700''401300''330F00''260C00''1A0800''0D0400''000000');
    $farben[]  = array('FFFFFF''FFF7F2''FFEFE6''FFE6D9''FFDECC''FFD6BF',  'FFCEB3''FFC5A6''FFBD99''FFB58C''FFAD80''FFA473''FF9C66',  'FF9459''FF8C4D''FF8340''FF7B33''FF7326''FF6B1A''FF620D',  'FF5A00''F25600''E65100''D94D00''CC4800''BF4400''B33F00',  'A63B00''993600''8C3200''802D00''732900''662400''592000',  '4D1B00''401700''331200''260E00''1A0900''0D0500''000000');
    $farben[]  = array('FFFFFF''FFF7F2''FFF0E6''FFE8D9''FFE0CC''FFD9BF',  'FFD1B3''FFC9A6''FFC299''FFBA8C''FFB380''FFAB73''FFA366',  'FF9C59''FF944D''FF8C40''FF8533''FF7D26''FF751A''FF6E0D',  'FF6600''F26100''E65C00''D95700''CC5200''BF4D00''B34700',  'A64200''993D00''8C3800''803300''732E00''662900''592400',  '4D1F00''401A00''331400''260F00''1A0A00''0D0500''000000');
    $farben[]  = array('FFFFFF''FFF8F2''FFF1E6''FFEAD9''FFE3CC''FFDCBF',  'FFD5B3''FFCEA6''FFC799''FFC08C''FFB980''FFB273''FFAB66',  'FFA459''FF9D4D''FF9640''FF8F33''FF8826''FF811A''FF7A0D',  'FF7300''F26D00''E66800''D96200''CC5C00''BF5600''B35100',  'A64B00''994500''8C3F00''803A00''733400''662E00''592800',  '4D2300''401D00''331700''261100''1A0C00''0D0600''000000');
    // Orange
    $farben[]  = array('FFFFFF''FFF9F2''FFF2E6''FFECD9''FFE6CC''FFDFBF',  'FFD9B3''FFD3A6''FFCC99''FFC68C''FFC080''FFB973''FFB366',  'FFAC59''FFA64D''FFA040''FF9933''FF9326''FF8D1A''FF860D',  'FF8000''F27A00''E67300''D96D00''CC6600''BF6000''B35A00',  'A65300''994D00''8C4600''804000''733A00''663300''592D00',  '4D2600''402000''331A00''261300''1A0D00''0D0600''000000');
    $farben[]  = array('FFFFFF''FFF9F2''FFF4E6''FFEED9''FFE8CC''FFE3BF',  'FFDDB3''FFD7A6''FFD199''FFCC8C''FFC680''FFC073''FFBB66',  'FFB559''FFAF4D''FFAA40''FFA433''FF9E26''FF981A''FF930D',  'FF8D00''F28600''E67F00''D97800''CC7100''BF6A00''B36300',  'A65C00''995500''8C4E00''804700''733F00''663800''593100',  '4D2A00''402300''331C00''261500''1A0E00''0D0700''000000');
    $farben[]  = array('FFFFFF''FFFAF2''FFF5E6''FFF0D9''FFEBCC''FFE6BF',  'FFE0B3''FFDBA6''FFD699''FFD18C''FFCC80''FFC773''FFC266',  'FFBD59''FFB84D''FFB340''FFAD33''FFA826''FFA31A''FF9E0D',  'FF9900''F29100''E68A00''D98200''CC7A00''BF7300''B36B00',  'A66300''995C00''8C5400''804D00''734500''663D00''593600',  '4D2E00''402600''331F00''261700''1A0F00''0D0800''000000');
    $farben[]  = array('FFFFFF''FFFBF2''FFF6E6''FFF2D9''FFEDCC''FFE9BF',  'FFE4B3''FFE0A6''FFDB99''FFD78C''FFD380''FFCE73''FFCA66',  'FFC559''FFC14D''FFBC40''FFB833''FFB326''FFAF1A''FFAA0D',  'FFA600''F29E00''E69500''D98D00''CC8500''BF7D00''B37400',  'A66C00''996400''8C5B00''805300''734B00''664200''593A00',  '4D3200''402A00''332100''261900''1A1100''0D0800''000000');
    $farben[]  = array('FFFFFF''FFFBF2''FFF7E6''FFF4D9''FFF0CC''FFECBF',  'FFE8B3''FFE4A6''FFE199''FFDD8C''FFD980''FFD573''FFD166',  'FFCE59''FFCA4D''FFC640''FFC233''FFBE26''FFBB1A''FFB70D',  'FFB300''F2AA00''E6A100''D99800''CC8F00''BF8600''B37D00',  'A67400''996B00''8C6200''805A00''735100''664800''593F00',  '4D3600''402D00''332400''261B00''1A1200''0D0900''000000');
    $farben[]  = array('FFFFFF''FFFCF2''FFF9E6''FFF6D9''FFF2CC''FFEFBF',  'FFECB3''FFE9A6''FFE699''FFE38C''FFE080''FFDC73''FFD966',  'FFD659''FFD34D''FFD040''FFCD33''FFC926''FFC61A''FFC30D',  'FFC000''F2B600''E6AD00''D9A300''CC9A00''BF9000''B38600',  'A67D00''997300''8C6A00''806000''735600''664D00''594300',  '4D3A00''403000''332600''261D00''1A1300''0D0A00''000000');
    $farben[]  = array('FFFFFF''FFFCF2''FFFAE6''FFF7D9''FFF5CC''FFF2BF',  'FFF0B3''FFEDA6''FFEB99''FFE88C''FFE680''FFE373''FFE066',  'FFDE59''FFDB4D''FFD940''FFD633''FFD426''FFD11A''FFCF0D',  'FFCC00''F2C200''E6B800''D9AD00''CCA300''BF9900''B38F00',  'A68500''997A00''8C7000''806600''735C00''665200''594700',  '4D3D00''403300''332900''261F00''1A1400''0D0A00''000000');
    $farben[]  = array('FFFFFF''FFFDF2''FFFBE6''FFF9D9''FFF7CC''FFF6BF',  'FFF4B3''FFF2A6''FFF099''FFEE8C''FFEC80''FFEA73''FFE866',  'FFE659''FFE44D''FFE340''FFE133''FFDF26''FFDD1A''FFDB0D',  'FFD900''F2CE00''E6C300''D9B800''CCAE00''BFA300''B39800',  'A68D00''998200''8C7700''806D00''736200''665700''594C00',  '4D4100''403600''332B00''262100''1A1600''0D0B00''000000');
    $farben[]  = array('FFFFFF''FFFEF2''FFFDE6''FFFBD9''FFFACC''FFF9BF',  'FFF8B3''FFF6A6''FFF599''FFF48C''FFF380''FFF173''FFF066',  'FFEF59''FFEE4D''FFEC40''FFEB33''FFEA26''FFE91A''FFE70D',  'FFE600''F2DB00''E6CF00''D9C400''CCB800''BFAD00''B3A100',  'A69600''998A00''8C7F00''807300''736800''665C00''595100',  '4D4500''403A00''332E00''262300''1A1700''0D0C00''000000');
    $farben[]  = array('FFFFFF''FFFEF2''FFFEE6''FFFDD9''FFFCCC''FFFCBF',  'FFFBB3''FFFAA6''FFFA99''FFF98C''FFF980''FFF873''FFF766',  'FFF759''FFF64D''FFF540''FFF533''FFF426''FFF31A''FFF30D',  'FFF200''F2E600''E6DA00''D9CE00''CCC200''BFB600''B3A900',  'A69D00''999100''8C8500''807900''736D00''666100''595500',  '4D4900''403D00''333000''262400''1A1800''0D0C00''000000');
    // Gelb
    $farben[]  = array('FFFFFF''FFFFF2''FFFFE6''FFFFD9''FFFFCC''FFFFBF',  'FFFFB3''FFFFA6''FFFF99''FFFF8C''FFFF80''FFFF73''FFFF66',  'FFFF59''FFFF4D''FFFF40''FFFF33''FFFF26''FFFF1A''FFFF0D',  'FFFF00''F2F200''E6E600''D9D900''CCCC00''BFBF00''B3B300',  'A6A600''999900''8C8C00''808000''737300''666600''595900',  '4D4D00''404000''333300''262600''1A1A00''0D0D00''000000');
    $farben[]  = array('FFFFFF''FEFFF2''FDFFE6''FBFFD9''FAFFCC''F9FFBF',  'F8FFB3''F6FFA6''F5FF99''F4FF8C''F3FF80''F1FF73''F0FF66',  'EFFF59''EEFF4D''ECFF40''EBFF33''EAFF26''E9FF1A''E7FF0D',  'E6FF00''DBF200''CFE600''C4D900''B8CC00''ADBF00''A1B300',  '96A600''8A9900''7F8C00''738000''687300''5C6600''515900',  '454D00''3A4000''2E3300''232600''171A00''0C0D00''000000');
    $farben[]  = array('FFFFFF''FCFFF2''FAFFE6''F7FFD9''F5FFCC''F2FFBF',  'F0FFB3''EDFFA6''EBFF99''E8FF8C''E6FF80''E3FF73''E0FF66',  'DEFF59''DBFF4D''D9FF40''D6FF33''D4FF26''D1FF1A''CFFF0D',  'CCFF00''C2F200''B8E600''ADD900''A3CC00''99BF00''8FB300',  '85A600''7A9900''708C00''668000''5C7300''526600''475900',  '3D4D00''334000''293300''1F2600''141A00''0A0D00''000000');
    $farben[]  = array('FFFFFF''FBFFF2''F7FFE6''F4FFD9''F0FFCC''ECFFBF',  'E8FFB3''E4FFA6''E1FF99''DDFF8C''D9FF80''D5FF73''D1FF66',  'CEFF59''CAFF4D''C6FF40''C2FF33''BEFF26''BBFF1A''B7FF0D',  'B3FF00''AAF200''A1E600''98D900''8FCC00''86BF00''7DB300',  '74A600''6B9900''628C00''5A8000''517300''486600''3F5900',  '364D00''2D4000''243300''1B2600''121A00''090D00''000000');
    $farben[]  = array('FFFFFF''FAFFF2''F5FFE6''F0FFD9''EBFFCC''E6FFBF',  'E0FFB3''DBFFA6''D6FF99''D1FF8C''CCFF80''C7FF73''C2FF66',  'BDFF59''B8FF4D''B3FF40''ADFF33''A8FF26''A3FF1A''9EFF0D',  '99FF00''91F200''8AE600''82D900''7ACC00''73BF00''6BB300',  '63A600''5C9900''548C00''4D8000''457300''3D6600''365900',  '2E4D00''264000''1F3300''172600''0F1A00''080D00''000000');
    $farben[]  = array('FFFFFF''F9FFF2''F2FFE6''ECFFD9''E6FFCC''DFFFBF',  'D9FFB3''D3FFA6''CCFF99''C6FF8C''C0FF80''B9FF73''B3FF66',  'ACFF59''A6FF4D''A0FF40''99FF33''93FF26''8DFF1A''86FF0D',  '80FF00''7AF200''73E600''6DD900''66CC00''60BF00''5AB300',  '53A600''4D9900''468C00''408000''3A7300''336600''2D5900',  '264D00''204000''1A3300''132600''0D1A00''060D00''000000');
    $farben[]  = array('FFFFFF''F7FFF2''F0FFE6''E8FFD9''E0FFCC''D9FFBF',  'D1FFB3''C9FFA6''C2FF99''BAFF8C''B3FF80''ABFF73''A3FF66',  '9CFF59''94FF4D''8CFF40''85FF33''7DFF26''75FF1A''6EFF0D',  '66FF00''61F200''5CE600''57D900''52CC00''4DBF00''47B300',  '42A600''3D9900''388C00''338000''2E7300''296600''245900',  '1F4D00''1A4000''143300''0F2600''0A1A00''050D00''000000');
    $farben[]  = array('FFFFFF''F6FFF2''EDFFE6''E4FFD9''DBFFCC''D3FFBF',  'CAFFB3''C1FFA6''B8FF99''AFFF8C''A6FF80''9DFF73''94FF66',  '8BFF59''82FF4D''7AFF40''71FF33''68FF26''5FFF1A''56FF0D',  '4DFF00''49F200''45E600''41D900''3ECC00''3ABF00''36B300',  '32A600''2E9900''2A8C00''278000''237300''1F6600''1B5900',  '174D00''134000''0F3300''0C2600''081A00''040D00''000000');
    $farben[]  = array('FFFFFF''F5FFF2''EBFFE6''E0FFD9''D6FFCC''CCFFBF',  'C2FFB3''B8FFA6''ADFF99''A3FF8C''99FF80''8FFF73''85FF66',  '7AFF59''70FF4D''66FF40''5CFF33''52FF26''47FF1A''3DFF0D',  '33FF00''30F200''2EE600''2BD900''29CC00''26BF00''24B300',  '21A600''1F9900''1C8C00''1A8000''177300''146600''125900',  '0F4D00''0D4000''0A3300''082600''051A00''030D00''000000');
    $farben[]  = array('FFFFFF''F4FFF2''E8FFE6''DDFFD9''D1FFCC''C6FFBF',  'BAFFB3''AFFFA6''A3FF99''98FF8C''8DFF80''81FF73''76FF66',  '6AFF59''5FFF4D''53FF40''48FF33''3CFF26''31FF1A''25FF0D',  '1AFF00''19F200''17E600''16D900''15CC00''14BF00''12B300',  '11A600''109900''0E8C00''0D8000''0C7300''0A6600''095900',  '084D00''074000''053300''042600''031A00''010D00''000000');
    // Grün
    $farben[]  = array('FFFFFF''F2FFF2''E6FFE6''D9FFD9''CCFFCC''BFFFBF',  'B3FFB3''A6FFA6''99FF99''8CFF8C''80FF80''73FF73''66FF66',  '59FF59''4DFF4D''40FF40''33FF33''26FF26''1AFF1A''0DFF0D',  '00FF00''00F200''00E600''00D900''00CC00''00BF00''00B300',  '00A600''009900''008C00''008000''007300''006600''005900',  '004D00''004000''003300''002600''001A00''000D00''000000');
    $farben[]  = array('FFFFFF''F2FFF4''E6FFE8''D9FFDD''CCFFD1''BFFFC6',  'B3FFBA''A6FFAF''99FFA3''8CFF98''80FF8D''73FF81''66FF76',  '59FF6A''4DFF5F''40FF53''33FF48''26FF3C''1AFF31''0DFF25',  '00FF1A''00F219''00E617''00D916''00CC15''00BF14''00B312',  '00A611''009910''008C0E''00800D''00730C''00660A''005909',  '004D08''004007''003305''002604''001A03''000D01''000000');
    $farben[]  = array('FFFFFF''F2FFF5''E6FFEB''D9FFE0''CCFFD6''BFFFCC',  'B3FFC2''A6FFB8''99FFAD''8CFFA3''80FF99''73FF8F''66FF85',  '59FF7A''4DFF70''40FF66''33FF5C''26FF52''1AFF47''0DFF3D',  '00FF33''00F230''00E62E''00D92B''00CC29''00BF26''00B324',  '00A621''00991F''008C1C''00801A''007317''006614''005912',  '004D0F''00400D''00330A''002608''001A05''000D03''000000');
    $farben[]  = array('FFFFFF''F2FFF6''E6FFED''D9FFE4''CCFFDB''BFFFD3',  'B3FFCA''A6FFC1''99FFB8''8CFFAF''80FFA6''73FF9D''66FF94',  '59FF8B''4DFF82''40FF7A''33FF71''26FF68''1AFF5F''0DFF56',  '00FF4D''00F249''00E645''00D941''00CC3E''00BF3A''00B336',  '00A632''00992E''008C2A''008027''007323''00661F''00591B',  '004D17''004013''00330F''00260C''001A08''000D04''000000');
    $farben[]  = array('FFFFFF''F2FFF7''E6FFF0''D9FFE8''CCFFE0''BFFFD9',  'B3FFD1''A6FFC9''99FFC2''8CFFBA''80FFB3''73FFAB''66FFA3',  '59FF9C''4DFF94''40FF8C''33FF85''26FF7D''1AFF75''0DFF6E',  '00FF66''00F261''00E65C''00D957''00CC52''00BF4D''00B347',  '00A642''00993D''008C38''008033''00732E''006629''005924',  '004D1F''00401A''003314''00260F''001A0A''000D05''000000');
    $farben[]  = array('FFFFFF''F2FFF9''E6FFF2''D9FFEC''CCFFE6''BFFFDF',  'B3FFD9''A6FFD3''99FFCC''8CFFC6''80FFC0''73FFB9''66FFB3',  '59FFAC''4DFFA6''40FFA0''33FF99''26FF93''1AFF8D''0DFF86',  '00FF80''00F27A''00E673''00D96D''00CC66''00BF60''00B35A',  '00A653''00994D''008C46''008040''00733A''006633''00592D',  '004D26''004020''00331A''002613''001A0D''000D06''000000');
    $farben[]  = array('FFFFFF''F2FFFA''E6FFF5''D9FFF0''CCFFEB''BFFFE6',  'B3FFE0''A6FFDB''99FFD6''8CFFD1''80FFCC''73FFC7''66FFC2',  '59FFBD''4DFFB8''40FFB3''33FFAD''26FFA8''1AFFA3''0DFF9E',  '00FF99''00F291''00E68A''00D982''00CC7A''00BF73''00B36B',  '00A663''00995C''008C54''00804D''007345''00663D''005936',  '004D2E''004026''00331F''002617''001A0F''000D08''000000');
    $farben[]  = array('FFFFFF''F2FFFB''E6FFF7''D9FFF4''CCFFF0''BFFFEC',  'B3FFE8''A6FFE4''99FFE1''8CFFDD''80FFD9''73FFD5''66FFD1',  '59FFCE''4DFFCA''40FFC6''33FFC2''26FFBE''1AFFBB''0DFFB7',  '00FFB3''00F2AA''00E6A1''00D998''00CC8F''00BF86''00B37D',  '00A674''00996B''008C62''00805A''007351''006648''00593F',  '004D36''00402D''003324''00261B''001A12''000D09''000000');
    $farben[]  = array('FFFFFF''F2FFFC''E6FFFA''D9FFF7''CCFFF5''BFFFF2',  'B3FFF0''A6FFED''99FFEB''8CFFE8''80FFE6''73FFE3''66FFE0',  '59FFDE''4DFFDB''40FFD9''33FFD6''26FFD4''1AFFD1''0DFFCF',  '00FFCC''00F2C2''00E6B8''00D9AD''00CCA3''00BF99''00B38F',  '00A685''00997A''008C70''008066''00735C''006652''005947',  '004D3D''004033''003329''00261F''001A14''000D0A''000000');
    $farben[]  = array('FFFFFF''F2FFFE''E6FFFD''D9FFFB''CCFFFA''BFFFF9',  'B3FFF8''A6FFF6''99FFF5''8CFFF4''80FFF3''73FFF1''66FFF0',  '59FFEF''4DFFEE''40FFEC''33FFEB''26FFEA''1AFFE9''0DFFE7',  '00FFE6''00F2DB''00E6CF''00D9C4''00CCB8''00BFAD''00B3A1',  '00A696''00998A''008C7F''008073''007368''00665C''005951',  '004D45''00403A''00332E''002623''001A17''000D0C''000000');
    // Cyan
    $farben[]  = array('FFFFFF''F2FFFF''E6FFFF''D9FFFF''CCFFFF''BFFFFF',  'B3FFFF''A6FFFF''99FFFF''8CFFFF''80FFFF''73FFFF''66FFFF',  '59FFFF''4DFFFF''40FFFF''33FFFF''26FFFF''1AFFFF''0DFFFF',  '00FFFF''00F2F2''00E6E6''00D9D9''00CCCC''00BFBF''00B3B3',  '00A6A6''009999''008C8C''008080''007373''006666''005959',  '004D4D''004040''003333''002626''001A1A''000D0D''000000');
    $farben[]  = array('FFFFFF''F2FEFF''E6FDFF''D9FBFF''CCFAFF''BFF9FF',  'B3F8FF''A6F6FF''99F5FF''8CF4FF''80F3FF''73F1FF''66F0FF',  '59EFFF''4DEEFF''40ECFF''33EBFF''26EAFF''1AE9FF''0DE7FF',  '00E6FF''00DBF2''00CFE6''00C4D9''00B8CC''00ADBF''00A1B3',  '0096A6''008A99''007F8C''007380''006873''005C66''005159',  '00454D''003A40''002E33''002326''00171A''000C0D''000000');
    $farben[]  = array('FFFFFF''F2FCFF''E6FAFF''D9F7FF''CCF5FF''BFF2FF',  'B3F0FF''A6EDFF''99EBFF''8CE8FF''80E6FF''73E3FF''66E0FF',  '59DEFF''4DDBFF''40D9FF''33D6FF''26D4FF''1AD1FF''0DCFFF',  '00CCFF''00C2F2''00B8E6''00ADD9''00A3CC''0099BF''008FB3',  '0085A6''007A99''00708C''006680''005C73''005266''004759',  '003D4D''003340''002933''001F26''00141A''000A0D''000000');
    $farben[]  = array('FFFFFF''F2FBFF''E6F7FF''D9F4FF''CCF0FF''BFECFF',  'B3E8FF''A6E4FF''99E1FF''8CDDFF''80D9FF''73D5FF''66D1FF',  '59CEFF''4DCAFF''40C6FF''33C2FF''26BEFF''1ABBFF''0DB7FF',  '00B3FF''00AAF2''00A1E6''0098D9''008FCC''0086BF''007DB3',  '0074A6''006B99''00628C''005A80''005173''004866''003F59',  '00364D''002D40''002433''001B26''00121A''00090D''000000');
    $farben[] = array('0099FF');
    $farben[] = array('0080FF');
    $farben[] = array('0066FF');
    $farben[] = array('004DFF');
    $farben[] = array('0033FF');
    $farben[] = array('001AFF');
    // Blau
    $farben[] = array('0000FF');
    $farben[] = array('0B00FF');
    $farben[] = array('1600FF');
    $farben[] = array('2100FF');
    $farben[] = array('2C00FF');
    $farben[] = array('3800FF');
    $farben[] = array('4300FF');
    $farben[] = array('4E00FF');
    $farben[] = array('5900FF');
    $farben[] = array('6400FF');
    // Indigo
    $farben[] = array('6F00FF');
    $farben[] = array('7D00FF');
    $farben[] = array('8C00FF');
    $farben[] = array('9A00FF');
    $farben[] = array('A900FF');
    $farben[] = array('B700FF');
    $farben[] = array('C500FF');
    $farben[] = array('D400FF');
    $farben[] = array('E200FF');
    $farben[] = array('F100FF');
    // Magenta
    $farben[] = array('FF00FF');
    $farben[] = array('FF00E6');
    $farben[] = array('FF00CC');
    $farben[] = array('FF00B3');
    $farben[] = array('FF0099');
    $farben[] = array('FF0080');
    $farben[] = array('FF0066');
    $farben[] = array('FF004D');
    $farben[] = array('FF0033');
    $farben[] = array('FF001A');

    $count 1;
    foreach(
    $farben as $arr){
        foreach(
    $arr as $value){
            if(
    $value == 'FFFFFF' OR $value == '000000'){$text $count;}
            else{
    $text '&nbsp;';}
            
            if(
    $value == '000000'){$color ' color:#FFFFFF;';}
            else{
    $color '';}
            
             
    $preoutput .= '<div style="background-color:#'.$value.';'.$color.'"  title="'.$value.'">'.$text.'</div>'."\n";
        }
         
    $output .= '<div  class="row">'."\n".$preoutput."\n".'</div><div  class="clear">&nbsp;</div>'."\n";
        
        
    $preoutput '';
        
    $count++;
    }
    ?>
    <!DOCTYPE html>
    <html lang="de">
    <head>
        <title>Farbpalette</title>
        <meta charset="utf-8">
        <style type="text/css">
            body{
              font-family:arial,tahoma,sans-serif;
              font-size:0.8em;
            }
            .row div{
                float:left;
                width:2.338%;
                height:2em;
                text-align:center;
                border:solid 1px #000000;
                border-right:0;
                border-bottom:0;
            }
            .clear{
                clear:left;
                height:0;
            }
        </style>
    </head>
    <body>
    <div class="row">
    <div>+20</div>
    <div>+19</div>
    <div>+18</div>
    <div>+17</div>
    <div>+16</div>
    <div>+15</div>
    <div>+14</div>
    <div>+13</div>
    <div>+12</div>
    <div>+11</div>
    <div>+10</div>
    <div>+9</div>
    <div>+8</div>
    <div>+7</div>
    <div>+6</div>
    <div>+5</div>
    <div>+4</div>
    <div>+3</div>
    <div>+2</div>
    <div>+1</div>
    <div>0</div>
    <div>-1</div>
    <div>-2</div>
    <div>-3</div>
    <div>-4</div>
    <div>-5</div>
    <div>-6</div>
    <div>-7</div>
    <div>-8</div>
    <div>-9</div>
    <div>-10</div>
    <div>-11</div>
    <div>-12</div>
    <div>-13</div>
    <div>-14</div>
    <div>-15</div>
    <div>-16</div>
    <div>-17</div>
    <div>-18</div>
    <div>-19</div>
    <div>-20</div>
    </div>

    <?php echo $output?>
    </body>
    </html>

  4. #4
    Bandit
    Gast

    Standard AW: foreach-Schleife; eigenartiges Problem

    Hmm, eine interessante Sache. Auf die Schnelle sehe ich da auch nichts, müsste man mal genauer forschen. Allerdings habe ich jetzt keine Zeit dazu, frühestens heute Abend.

  5. #5
    Bandit
    Gast

    Standard AW: foreach-Schleife; eigenartiges Problem

    Das scheint wohl ein PHP-Bug zu sein, denn bei
    PHP-Code:
    <?php
        
    if ("00E600" == "000000")
        echo 
    "00E600 == 000000<br>";
      else
        echo 
    "00E600" != "000000<br>";
        
      if (
    "00E617" == "000000")
        echo 
    "00E617 == 000000<br>";
      else
        echo 
    "00E617 != 000000<br>";
        
      if (
    "00E645" == "000000")
        echo 
    "00E645 == 000000<br>";
      else
        echo 
    "00E645 != 000000<br>";
        
      if (
    "00E673" == "000000")
        echo 
    "00E673 == 000000<br>";
      else
        echo 
    "00E673 != 000000<br>";
    ?>
    kommt tatsächlich raus:
    00E600 == 000000
    00E617 == 000000
    00E645 == 000000
    00E673 == 000000

  6. Folgende User finden die Antwort von Bandit gut:


  7. #6
    Teeny
    Themenstarter

    Registriert seit
    06.01.2014
    Beiträge
    27
    Danke
    1
    Bekam 1 mal "Danke" in 1 Posting

    Standard AW: foreach-Schleife; eigenartiges Problem

    Oh das ist ja krass
    Dachte schon ich verlier meinen Verstand.

    Sehr innovative Methode von Dir das zu Testen - wär mir im Traum nicht eingefallen zu testen ob 2 verschiedene Farbwerte nicht doch gleich sind

    Vielen Dank dafür!

    Mal sehen wie ich das gefixt bekomme...

    Ich teile meine Lösung hier mit.

    Grüße und Danke nochmals

  8. #7
    Bandit
    Gast

    Standard AW: foreach-Schleife; eigenartiges Problem

    So geht's:
    PHP-Code:
    <?php  
        
      
    if ("00E600" == "000000")
        echo 
    "00E600 == 000000<br>";
      else
        echo 
    "00E600" != "000000<br>";
        
      if (
    "00E617" == "000000")
        echo 
    "00E617 == 000000<br>";
      else
        echo 
    "00E617 != 000000<br>";
        
      if (
    "00E645" == "000000")
        echo 
    "00E645 == 000000<br>";
      else
        echo 
    "00E645 != 000000<br>";
        
      if (
    "00E673" == "000000")
        echo 
    "00E673 == 000000<br>";
      else
        echo 
    "00E673 != 000000<br>";
        
      
    $ret strcmp("00E600""000000");
      if (
    $ret)
         echo 
    "Ungleich<br>";
      else
         echo 
    "Gleich<br>";
         
      
    $ret strcmp("00E617""000000");
        if (
    $ret)
         echo 
    "Ungleich<br>";
      else
         echo 
    "Gleich<br>";
         
      
    $ret strcmp("00E645""000000");
        if (
    $ret)
         echo 
    "Ungleich<br>";
      else
         echo 
    "Gleich<br>";
         
      
    $ret strcmp("00E673""000000");
        if (
    $ret)
         echo 
    "Ungleich<br>";
      else
         echo 
    "Gleich<br>";
        
    ?>
    Ausgabe:
    00E600 == 000000
    00E617 == 000000
    00E645 == 000000
    00E673 == 000000
    Ungleich
    Ungleich
    Ungleich
    Ungleich
    Der direkte Vergleich geht in die Hose, mit strcmp ist's richtig

    - - - Aktualisiert - - -

    PHP-Code:
    <?php
    error_reporting
    (E_ALL);

    // Rot
    $farben[]  = array('FFFFFF''FFF2F2''FFE6E6''FFD9D9''FFCCCC''FFBFBF',  'FFB3B3''FFA6A6''FF9999''FF8C8C''FF8080''FF7373''FF6666',  'FF5959''FF4D4D''FF4040''FF3333''FF2626''FF1A1A''FF0D0D',  'FF0000''F20000''E60000''D90000''CC0000''BF0000''B30000',  'A60000''990000''8C0000''800000''730000''660000''590000',  '4D0000''400000''330000''260000''1A0000''0D0000''000000');
    $farben[]  = array('FFFFFF''FFF3F2''FFE7E6''FFDBD9''FFCFCC''FFC3BF',  'FFB6B3''FFAAA6''FF9E99''FF928C''FF8680''FF7A73''FF6E66',  'FF6259''FF564D''FF4A40''FF3D33''FF3126''FF251A''FF190D',  'FF0D00''F20C00''E60C00''D90B00''CC0A00''BF0A00''B30900',  'A60800''990800''8C0700''800700''730600''660500''590500',  '4D0400''400300''330300''260200''1A0100''0D0100''000000');
    $farben[]  = array('FFFFFF''FFF4F2''FFE8E6''FFDDD9''FFD1CC''FFC6BF',  'FFBAB3''FFAFA6''FFA399''FF988C''FF8D80''FF8173''FF7666',  'FF6A59''FF5F4D''FF5340''FF4833''FF3C26''FF311A''FF250D',  'FF1A00''F21900''E61700''D91600''CC1500''BF1400''B31200',  'A61100''991000''8C0E00''800D00''730C00''660A00''590900',  '4D0800''400700''330500''260400''1A0300''0D0100''000000');
    $farben[]  = array('FFFFFF''FFF4F2''FFE9E6''FFDED9''FFD4CC''FFC9BF',  'FFBEB3''FFB3A6''FFA899''FF9D8C''FF9380''FF8873''FF7D66',  'FF7259''FF674D''FF5C40''FF5133''FF4726''FF3C1A''FF310D',  'FF2600''F22400''E62200''D92000''CC1E00''BF1D00''B31B00',  'A61900''991700''8C1500''801300''731100''660F00''590D00',  '4D0B00''400A00''330800''260600''1A0400''0D0200''000000');
    $farben[]  = array('FFFFFF''FFF5F2''FFEBE6''FFE0D9''FFD6CC''FFCCBF',  'FFC2B3''FFB8A6''FFAD99''FFA38C''FF9980''FF8F73''FF8566',  'FF7A59''FF704D''FF6640''FF5C33''FF5226''FF471A''FF3D0D',  'FF3300''F23000''E62E00''D92B00''CC2900''BF2600''B32400',  'A62100''991F00''8C1C00''801A00''731700''661400''591200',  '4D0F00''400D00''330A00''260800''1A0500''0D0300''000000');
    $farben[]  = array('FFFFFF''FFF5F2''FFECE6''FFE2D9''FFD9CC''FFCFBF',  'FFC6B3''FFBCA6''FFB399''FFA98C''FFA080''FF9673''FF8C66',  'FF8359''FF794D''FF7040''FF6633''FF5D26''FF531A''FF4A0D',  'FF4000''F23D00''E63A00''D93600''CC3300''BF3000''B32D00',  'A62A00''992600''8C2300''802000''731D00''661A00''591600',  '4D1300''401000''330D00''260A00''1A0600''0D0300''000000');
    $farben[]  = array('FFFFFF''FFF6F2''FFEDE6''FFE4D9''FFDBCC''FFD3BF',  'FFCAB3''FFC1A6''FFB899''FFAF8C''FFA680''FF9D73''FF9466',  'FF8B59''FF824D''FF7A40''FF7133''FF6826''FF5F1A''FF560D',  'FF4D00''F24900''E64500''D94100''CC3E00''BF3A00''B33600',  'A63200''992E00''8C2A00''802700''732300''661F00''591B00',  '4D1700''401300''330F00''260C00''1A0800''0D0400''000000');
    $farben[]  = array('FFFFFF''FFF7F2''FFEFE6''FFE6D9''FFDECC''FFD6BF',  'FFCEB3''FFC5A6''FFBD99''FFB58C''FFAD80''FFA473''FF9C66',  'FF9459''FF8C4D''FF8340''FF7B33''FF7326''FF6B1A''FF620D',  'FF5A00''F25600''E65100''D94D00''CC4800''BF4400''B33F00',  'A63B00''993600''8C3200''802D00''732900''662400''592000',  '4D1B00''401700''331200''260E00''1A0900''0D0500''000000');
    $farben[]  = array('FFFFFF''FFF7F2''FFF0E6''FFE8D9''FFE0CC''FFD9BF',  'FFD1B3''FFC9A6''FFC299''FFBA8C''FFB380''FFAB73''FFA366',  'FF9C59''FF944D''FF8C40''FF8533''FF7D26''FF751A''FF6E0D',  'FF6600''F26100''E65C00''D95700''CC5200''BF4D00''B34700',  'A64200''993D00''8C3800''803300''732E00''662900''592400',  '4D1F00''401A00''331400''260F00''1A0A00''0D0500''000000');
    $farben[]  = array('FFFFFF''FFF8F2''FFF1E6''FFEAD9''FFE3CC''FFDCBF',  'FFD5B3''FFCEA6''FFC799''FFC08C''FFB980''FFB273''FFAB66',  'FFA459''FF9D4D''FF9640''FF8F33''FF8826''FF811A''FF7A0D',  'FF7300''F26D00''E66800''D96200''CC5C00''BF5600''B35100',  'A64B00''994500''8C3F00''803A00''733400''662E00''592800',  '4D2300''401D00''331700''261100''1A0C00''0D0600''000000');
    // Orange
    $farben[]  = array('FFFFFF''FFF9F2''FFF2E6''FFECD9''FFE6CC''FFDFBF',  'FFD9B3''FFD3A6''FFCC99''FFC68C''FFC080''FFB973''FFB366',  'FFAC59''FFA64D''FFA040''FF9933''FF9326''FF8D1A''FF860D',  'FF8000''F27A00''E67300''D96D00''CC6600''BF6000''B35A00',  'A65300''994D00''8C4600''804000''733A00''663300''592D00',  '4D2600''402000''331A00''261300''1A0D00''0D0600''000000');
    $farben[]  = array('FFFFFF''FFF9F2''FFF4E6''FFEED9''FFE8CC''FFE3BF',  'FFDDB3''FFD7A6''FFD199''FFCC8C''FFC680''FFC073''FFBB66',  'FFB559''FFAF4D''FFAA40''FFA433''FF9E26''FF981A''FF930D',  'FF8D00''F28600''E67F00''D97800''CC7100''BF6A00''B36300',  'A65C00''995500''8C4E00''804700''733F00''663800''593100',  '4D2A00''402300''331C00''261500''1A0E00''0D0700''000000');
    $farben[]  = array('FFFFFF''FFFAF2''FFF5E6''FFF0D9''FFEBCC''FFE6BF',  'FFE0B3''FFDBA6''FFD699''FFD18C''FFCC80''FFC773''FFC266',  'FFBD59''FFB84D''FFB340''FFAD33''FFA826''FFA31A''FF9E0D',  'FF9900''F29100''E68A00''D98200''CC7A00''BF7300''B36B00',  'A66300''995C00''8C5400''804D00''734500''663D00''593600',  '4D2E00''402600''331F00''261700''1A0F00''0D0800''000000');
    $farben[]  = array('FFFFFF''FFFBF2''FFF6E6''FFF2D9''FFEDCC''FFE9BF',  'FFE4B3''FFE0A6''FFDB99''FFD78C''FFD380''FFCE73''FFCA66',  'FFC559''FFC14D''FFBC40''FFB833''FFB326''FFAF1A''FFAA0D',  'FFA600''F29E00''E69500''D98D00''CC8500''BF7D00''B37400',  'A66C00''996400''8C5B00''805300''734B00''664200''593A00',  '4D3200''402A00''332100''261900''1A1100''0D0800''000000');
    $farben[]  = array('FFFFFF''FFFBF2''FFF7E6''FFF4D9''FFF0CC''FFECBF',  'FFE8B3''FFE4A6''FFE199''FFDD8C''FFD980''FFD573''FFD166',  'FFCE59''FFCA4D''FFC640''FFC233''FFBE26''FFBB1A''FFB70D',  'FFB300''F2AA00''E6A100''D99800''CC8F00''BF8600''B37D00',  'A67400''996B00''8C6200''805A00''735100''664800''593F00',  '4D3600''402D00''332400''261B00''1A1200''0D0900''000000');
    $farben[]  = array('FFFFFF''FFFCF2''FFF9E6''FFF6D9''FFF2CC''FFEFBF',  'FFECB3''FFE9A6''FFE699''FFE38C''FFE080''FFDC73''FFD966',  'FFD659''FFD34D''FFD040''FFCD33''FFC926''FFC61A''FFC30D',  'FFC000''F2B600''E6AD00''D9A300''CC9A00''BF9000''B38600',  'A67D00''997300''8C6A00''806000''735600''664D00''594300',  '4D3A00''403000''332600''261D00''1A1300''0D0A00''000000');
    $farben[]  = array('FFFFFF''FFFCF2''FFFAE6''FFF7D9''FFF5CC''FFF2BF',  'FFF0B3''FFEDA6''FFEB99''FFE88C''FFE680''FFE373''FFE066',  'FFDE59''FFDB4D''FFD940''FFD633''FFD426''FFD11A''FFCF0D',  'FFCC00''F2C200''E6B800''D9AD00''CCA300''BF9900''B38F00',  'A68500''997A00''8C7000''806600''735C00''665200''594700',  '4D3D00''403300''332900''261F00''1A1400''0D0A00''000000');
    $farben[]  = array('FFFFFF''FFFDF2''FFFBE6''FFF9D9''FFF7CC''FFF6BF',  'FFF4B3''FFF2A6''FFF099''FFEE8C''FFEC80''FFEA73''FFE866',  'FFE659''FFE44D''FFE340''FFE133''FFDF26''FFDD1A''FFDB0D',  'FFD900''F2CE00''E6C300''D9B800''CCAE00''BFA300''B39800',  'A68D00''998200''8C7700''806D00''736200''665700''594C00',  '4D4100''403600''332B00''262100''1A1600''0D0B00''000000');
    $farben[]  = array('FFFFFF''FFFEF2''FFFDE6''FFFBD9''FFFACC''FFF9BF',  'FFF8B3''FFF6A6''FFF599''FFF48C''FFF380''FFF173''FFF066',  'FFEF59''FFEE4D''FFEC40''FFEB33''FFEA26''FFE91A''FFE70D',  'FFE600''F2DB00''E6CF00''D9C400''CCB800''BFAD00''B3A100',  'A69600''998A00''8C7F00''807300''736800''665C00''595100',  '4D4500''403A00''332E00''262300''1A1700''0D0C00''000000');
    $farben[]  = array('FFFFFF''FFFEF2''FFFEE6''FFFDD9''FFFCCC''FFFCBF',  'FFFBB3''FFFAA6''FFFA99''FFF98C''FFF980''FFF873''FFF766',  'FFF759''FFF64D''FFF540''FFF533''FFF426''FFF31A''FFF30D',  'FFF200''F2E600''E6DA00''D9CE00''CCC200''BFB600''B3A900',  'A69D00''999100''8C8500''807900''736D00''666100''595500',  '4D4900''403D00''333000''262400''1A1800''0D0C00''000000');
    // Gelb
    $farben[]  = array('FFFFFF''FFFFF2''FFFFE6''FFFFD9''FFFFCC''FFFFBF',  'FFFFB3''FFFFA6''FFFF99''FFFF8C''FFFF80''FFFF73''FFFF66',  'FFFF59''FFFF4D''FFFF40''FFFF33''FFFF26''FFFF1A''FFFF0D',  'FFFF00''F2F200''E6E600''D9D900''CCCC00''BFBF00''B3B300',  'A6A600''999900''8C8C00''808000''737300''666600''595900',  '4D4D00''404000''333300''262600''1A1A00''0D0D00''000000');
    $farben[]  = array('FFFFFF''FEFFF2''FDFFE6''FBFFD9''FAFFCC''F9FFBF',  'F8FFB3''F6FFA6''F5FF99''F4FF8C''F3FF80''F1FF73''F0FF66',  'EFFF59''EEFF4D''ECFF40''EBFF33''EAFF26''E9FF1A''E7FF0D',  'E6FF00''DBF200''CFE600''C4D900''B8CC00''ADBF00''A1B300',  '96A600''8A9900''7F8C00''738000''687300''5C6600''515900',  '454D00''3A4000''2E3300''232600''171A00''0C0D00''000000');
    $farben[]  = array('FFFFFF''FCFFF2''FAFFE6''F7FFD9''F5FFCC''F2FFBF',  'F0FFB3''EDFFA6''EBFF99''E8FF8C''E6FF80''E3FF73''E0FF66',  'DEFF59''DBFF4D''D9FF40''D6FF33''D4FF26''D1FF1A''CFFF0D',  'CCFF00''C2F200''B8E600''ADD900''A3CC00''99BF00''8FB300',  '85A600''7A9900''708C00''668000''5C7300''526600''475900',  '3D4D00''334000''293300''1F2600''141A00''0A0D00''000000');
    $farben[]  = array('FFFFFF''FBFFF2''F7FFE6''F4FFD9''F0FFCC''ECFFBF',  'E8FFB3''E4FFA6''E1FF99''DDFF8C''D9FF80''D5FF73''D1FF66',  'CEFF59''CAFF4D''C6FF40''C2FF33''BEFF26''BBFF1A''B7FF0D',  'B3FF00''AAF200''A1E600''98D900''8FCC00''86BF00''7DB300',  '74A600''6B9900''628C00''5A8000''517300''486600''3F5900',  '364D00''2D4000''243300''1B2600''121A00''090D00''000000');
    $farben[]  = array('FFFFFF''FAFFF2''F5FFE6''F0FFD9''EBFFCC''E6FFBF',  'E0FFB3''DBFFA6''D6FF99''D1FF8C''CCFF80''C7FF73''C2FF66',  'BDFF59''B8FF4D''B3FF40''ADFF33''A8FF26''A3FF1A''9EFF0D',  '99FF00''91F200''8AE600''82D900''7ACC00''73BF00''6BB300',  '63A600''5C9900''548C00''4D8000''457300''3D6600''365900',  '2E4D00''264000''1F3300''172600''0F1A00''080D00''000000');
    $farben[]  = array('FFFFFF''F9FFF2''F2FFE6''ECFFD9''E6FFCC''DFFFBF',  'D9FFB3''D3FFA6''CCFF99''C6FF8C''C0FF80''B9FF73''B3FF66',  'ACFF59''A6FF4D''A0FF40''99FF33''93FF26''8DFF1A''86FF0D',  '80FF00''7AF200''73E600''6DD900''66CC00''60BF00''5AB300',  '53A600''4D9900''468C00''408000''3A7300''336600''2D5900',  '264D00''204000''1A3300''132600''0D1A00''060D00''000000');
    $farben[]  = array('FFFFFF''F7FFF2''F0FFE6''E8FFD9''E0FFCC''D9FFBF',  'D1FFB3''C9FFA6''C2FF99''BAFF8C''B3FF80''ABFF73''A3FF66',  '9CFF59''94FF4D''8CFF40''85FF33''7DFF26''75FF1A''6EFF0D',  '66FF00''61F200''5CE600''57D900''52CC00''4DBF00''47B300',  '42A600''3D9900''388C00''338000''2E7300''296600''245900',  '1F4D00''1A4000''143300''0F2600''0A1A00''050D00''000000');
    $farben[]  = array('FFFFFF''F6FFF2''EDFFE6''E4FFD9''DBFFCC''D3FFBF',  'CAFFB3''C1FFA6''B8FF99''AFFF8C''A6FF80''9DFF73''94FF66',  '8BFF59''82FF4D''7AFF40''71FF33''68FF26''5FFF1A''56FF0D',  '4DFF00''49F200''45E600''41D900''3ECC00''3ABF00''36B300',  '32A600''2E9900''2A8C00''278000''237300''1F6600''1B5900',  '174D00''134000''0F3300''0C2600''081A00''040D00''000000');
    $farben[]  = array('FFFFFF''F5FFF2''EBFFE6''E0FFD9''D6FFCC''CCFFBF',  'C2FFB3''B8FFA6''ADFF99''A3FF8C''99FF80''8FFF73''85FF66',  '7AFF59''70FF4D''66FF40''5CFF33''52FF26''47FF1A''3DFF0D',  '33FF00''30F200''2EE600''2BD900''29CC00''26BF00''24B300',  '21A600''1F9900''1C8C00''1A8000''177300''146600''125900',  '0F4D00''0D4000''0A3300''082600''051A00''030D00''000000');
    $farben[]  = array('FFFFFF''F4FFF2''E8FFE6''DDFFD9''D1FFCC''C6FFBF',  'BAFFB3''AFFFA6''A3FF99''98FF8C''8DFF80''81FF73''76FF66',  '6AFF59''5FFF4D''53FF40''48FF33''3CFF26''31FF1A''25FF0D',  '1AFF00''19F200''17E600''16D900''15CC00''14BF00''12B300',  '11A600''109900''0E8C00''0D8000''0C7300''0A6600''095900',  '084D00''074000''053300''042600''031A00''010D00''000000');
    // Grün
    $farben[]  = array('FFFFFF''F2FFF2''E6FFE6''D9FFD9''CCFFCC''BFFFBF',  'B3FFB3''A6FFA6''99FF99''8CFF8C''80FF80''73FF73''66FF66',  '59FF59''4DFF4D''40FF40''33FF33''26FF26''1AFF1A''0DFF0D',  '00FF00''00F200''00E600''00D900''00CC00''00BF00''00B300',  '00A600''009900''008C00''008000''007300''006600''005900',  '004D00''004000''003300''002600''001A00''000D00''000000');
    $farben[]  = array('FFFFFF''F2FFF4''E6FFE8''D9FFDD''CCFFD1''BFFFC6',  'B3FFBA''A6FFAF''99FFA3''8CFF98''80FF8D''73FF81''66FF76',  '59FF6A''4DFF5F''40FF53''33FF48''26FF3C''1AFF31''0DFF25',  '00FF1A''00F219''00E617''00D916''00CC15''00BF14''00B312',  '00A611''009910''008C0E''00800D''00730C''00660A''005909',  '004D08''004007''003305''002604''001A03''000D01''000000');
    $farben[]  = array('FFFFFF''F2FFF5''E6FFEB''D9FFE0''CCFFD6''BFFFCC',  'B3FFC2''A6FFB8''99FFAD''8CFFA3''80FF99''73FF8F''66FF85',  '59FF7A''4DFF70''40FF66''33FF5C''26FF52''1AFF47''0DFF3D',  '00FF33''00F230''00E62E''00D92B''00CC29''00BF26''00B324',  '00A621''00991F''008C1C''00801A''007317''006614''005912',  '004D0F''00400D''00330A''002608''001A05''000D03''000000');
    $farben[]  = array('FFFFFF''F2FFF6''E6FFED''D9FFE4''CCFFDB''BFFFD3',  'B3FFCA''A6FFC1''99FFB8''8CFFAF''80FFA6''73FF9D''66FF94',  '59FF8B''4DFF82''40FF7A''33FF71''26FF68''1AFF5F''0DFF56',  '00FF4D''00F249''00E645''00D941''00CC3E''00BF3A''00B336',  '00A632''00992E''008C2A''008027''007323''00661F''00591B',  '004D17''004013''00330F''00260C''001A08''000D04''000000');
    $farben[]  = array('FFFFFF''F2FFF7''E6FFF0''D9FFE8''CCFFE0''BFFFD9',  'B3FFD1''A6FFC9''99FFC2''8CFFBA''80FFB3''73FFAB''66FFA3',  '59FF9C''4DFF94''40FF8C''33FF85''26FF7D''1AFF75''0DFF6E',  '00FF66''00F261''00E65C''00D957''00CC52''00BF4D''00B347',  '00A642''00993D''008C38''008033''00732E''006629''005924',  '004D1F''00401A''003314''00260F''001A0A''000D05''000000');
    $farben[]  = array('FFFFFF''F2FFF9''E6FFF2''D9FFEC''CCFFE6''BFFFDF',  'B3FFD9''A6FFD3''99FFCC''8CFFC6''80FFC0''73FFB9''66FFB3',  '59FFAC''4DFFA6''40FFA0''33FF99''26FF93''1AFF8D''0DFF86',  '00FF80''00F27A''00E673''00D96D''00CC66''00BF60''00B35A',  '00A653''00994D''008C46''008040''00733A''006633''00592D',  '004D26''004020''00331A''002613''001A0D''000D06''000000');
    $farben[]  = array('FFFFFF''F2FFFA''E6FFF5''D9FFF0''CCFFEB''BFFFE6',  'B3FFE0''A6FFDB''99FFD6''8CFFD1''80FFCC''73FFC7''66FFC2',  '59FFBD''4DFFB8''40FFB3''33FFAD''26FFA8''1AFFA3''0DFF9E',  '00FF99''00F291''00E68A''00D982''00CC7A''00BF73''00B36B',  '00A663''00995C''008C54''00804D''007345''00663D''005936',  '004D2E''004026''00331F''002617''001A0F''000D08''000000');
    $farben[]  = array('FFFFFF''F2FFFB''E6FFF7''D9FFF4''CCFFF0''BFFFEC',  'B3FFE8''A6FFE4''99FFE1''8CFFDD''80FFD9''73FFD5''66FFD1',  '59FFCE''4DFFCA''40FFC6''33FFC2''26FFBE''1AFFBB''0DFFB7',  '00FFB3''00F2AA''00E6A1''00D998''00CC8F''00BF86''00B37D',  '00A674''00996B''008C62''00805A''007351''006648''00593F',  '004D36''00402D''003324''00261B''001A12''000D09''000000');
    $farben[]  = array('FFFFFF''F2FFFC''E6FFFA''D9FFF7''CCFFF5''BFFFF2',  'B3FFF0''A6FFED''99FFEB''8CFFE8''80FFE6''73FFE3''66FFE0',  '59FFDE''4DFFDB''40FFD9''33FFD6''26FFD4''1AFFD1''0DFFCF',  '00FFCC''00F2C2''00E6B8''00D9AD''00CCA3''00BF99''00B38F',  '00A685''00997A''008C70''008066''00735C''006652''005947',  '004D3D''004033''003329''00261F''001A14''000D0A''000000');
    $farben[]  = array('FFFFFF''F2FFFE''E6FFFD''D9FFFB''CCFFFA''BFFFF9',  'B3FFF8''A6FFF6''99FFF5''8CFFF4''80FFF3''73FFF1''66FFF0',  '59FFEF''4DFFEE''40FFEC''33FFEB''26FFEA''1AFFE9''0DFFE7',  '00FFE6''00F2DB''00E6CF''00D9C4''00CCB8''00BFAD''00B3A1',  '00A696''00998A''008C7F''008073''007368''00665C''005951',  '004D45''00403A''00332E''002623''001A17''000D0C''000000');
    // Cyan
    $farben[]  = array('FFFFFF''F2FFFF''E6FFFF''D9FFFF''CCFFFF''BFFFFF',  'B3FFFF''A6FFFF''99FFFF''8CFFFF''80FFFF''73FFFF''66FFFF',  '59FFFF''4DFFFF''40FFFF''33FFFF''26FFFF''1AFFFF''0DFFFF',  '00FFFF''00F2F2''00E6E6''00D9D9''00CCCC''00BFBF''00B3B3',  '00A6A6''009999''008C8C''008080''007373''006666''005959',  '004D4D''004040''003333''002626''001A1A''000D0D''000000');
    $farben[]  = array('FFFFFF''F2FEFF''E6FDFF''D9FBFF''CCFAFF''BFF9FF',  'B3F8FF''A6F6FF''99F5FF''8CF4FF''80F3FF''73F1FF''66F0FF',  '59EFFF''4DEEFF''40ECFF''33EBFF''26EAFF''1AE9FF''0DE7FF',  '00E6FF''00DBF2''00CFE6''00C4D9''00B8CC''00ADBF''00A1B3',  '0096A6''008A99''007F8C''007380''006873''005C66''005159',  '00454D''003A40''002E33''002326''00171A''000C0D''000000');
    $farben[]  = array('FFFFFF''F2FCFF''E6FAFF''D9F7FF''CCF5FF''BFF2FF',  'B3F0FF''A6EDFF''99EBFF''8CE8FF''80E6FF''73E3FF''66E0FF',  '59DEFF''4DDBFF''40D9FF''33D6FF''26D4FF''1AD1FF''0DCFFF',  '00CCFF''00C2F2''00B8E6''00ADD9''00A3CC''0099BF''008FB3',  '0085A6''007A99''00708C''006680''005C73''005266''004759',  '003D4D''003340''002933''001F26''00141A''000A0D''000000');
    $farben[]  = array('FFFFFF''F2FBFF''E6F7FF''D9F4FF''CCF0FF''BFECFF',  'B3E8FF''A6E4FF''99E1FF''8CDDFF''80D9FF''73D5FF''66D1FF',  '59CEFF''4DCAFF''40C6FF''33C2FF''26BEFF''1ABBFF''0DB7FF',  '00B3FF''00AAF2''00A1E6''0098D9''008FCC''0086BF''007DB3',  '0074A6''006B99''00628C''005A80''005173''004866''003F59',  '00364D''002D40''002433''001B26''00121A''00090D''000000');
    $farben[] = array('0099FF');
    $farben[] = array('0080FF');
    $farben[] = array('0066FF');
    $farben[] = array('004DFF');
    $farben[] = array('0033FF');
    $farben[] = array('001AFF');
    // Blau
    $farben[] = array('0000FF');
    $farben[] = array('0B00FF');
    $farben[] = array('1600FF');
    $farben[] = array('2100FF');
    $farben[] = array('2C00FF');
    $farben[] = array('3800FF');
    $farben[] = array('4300FF');
    $farben[] = array('4E00FF');
    $farben[] = array('5900FF');
    $farben[] = array('6400FF');
    // Indigo
    $farben[] = array('6F00FF');
    $farben[] = array('7D00FF');
    $farben[] = array('8C00FF');
    $farben[] = array('9A00FF');
    $farben[] = array('A900FF');
    $farben[] = array('B700FF');
    $farben[] = array('C500FF');
    $farben[] = array('D400FF');
    $farben[] = array('E200FF');
    $farben[] = array('F100FF');
    // Magenta
    $farben[] = array('FF00FF');
    $farben[] = array('FF00E6');
    $farben[] = array('FF00CC');
    $farben[] = array('FF00B3');
    $farben[] = array('FF0099');
    $farben[] = array('FF0080');
    $farben[] = array('FF0066');
    $farben[] = array('FF004D');
    $farben[] = array('FF0033');
    $farben[] = array('FF001A');

    $count 1;
    $preoutput $output "";

    foreach(
    $farben as $arr){
        foreach(
    $arr as $value){
            if(! 
    strcmp($value"FFFFFF"))
              
    $text $count;
            else if (! 
    strcmp($value"000000"))
              
    $text $count;
            else
               
    $text '';
            
               
            if(
    $value == '000000'){$color ' color:#FFFFFF;';}
            else{
    $color '';}
            
             
    $preoutput .= '<div style="background-color:#'.$value.';'.$color.'"  title="'.$value.'">'.$text.'</div>'."\n";
        }
         
    $output .= '<div  class="row">'."\n".$preoutput."\n".'</div><div  class="clear">&nbsp;</div>'."\n";
        
        
    $preoutput '';
        
    $count++;
    }
    ?>
    <!DOCTYPE html>
    <html lang="de">
    <head>
        <title>Farbpalette</title>
        <meta charset="utf-8">
        <style type="text/css">
            body{
              font-family:arial,tahoma,sans-serif;
              font-size:0.8em;
            }
            .row div{
                float:left;
                width:2.338%;
                height:2em;
                text-align:center;
                border:solid 1px #000000;
                border-right:0;
                border-bottom:0;
            }
            .clear{
                clear:left;
                height:0;
            }
        </style>
    </head>
    <body>
    <div class="row">
    <div>+20</div>
    <div>+19</div>
    <div>+18</div>
    <div>+17</div>
    <div>+16</div>
    <div>+15</div>
    <div>+14</div>
    <div>+13</div>
    <div>+12</div>
    <div>+11</div>
    <div>+10</div>
    <div>+9</div>
    <div>+8</div>
    <div>+7</div>
    <div>+6</div>
    <div>+5</div>
    <div>+4</div>
    <div>+3</div>
    <div>+2</div>
    <div>+1</div>
    <div>0</div>
    <div>-1</div>
    <div>-2</div>
    <div>-3</div>
    <div>-4</div>
    <div>-5</div>
    <div>-6</div>
    <div>-7</div>
    <div>-8</div>
    <div>-9</div>
    <div>-10</div>
    <div>-11</div>
    <div>-12</div>
    <div>-13</div>
    <div>-14</div>
    <div>-15</div>
    <div>-16</div>
    <div>-17</div>
    <div>-18</div>
    <div>-19</div>
    <div>-20</div>
    </div>

    <?php echo $output?>

    </body>
    </html>
    Wenn das Script komplett fertig ist, hätte ich daran Interesse, ist eine feine Sache

  9. #8
    Teeny
    Themenstarter

    Registriert seit
    06.01.2014
    Beiträge
    27
    Danke
    1
    Bekam 1 mal "Danke" in 1 Posting

    Standard AW: foreach-Schleife; eigenartiges Problem

    Super!

    Vielen Dank Dir!

    Ich hätte jetzt einfach den String der einzelnen Farbwerte manipulliert, dann geht es auch:
    PHP-Code:
    $count 1;
    foreach(
    $farben as $arr){
        foreach(
    $arr as $value){
            
    $fix_value $value.'x';
            
            if(
    $fix_value == 'FFFFFFx' OR $fix_value == '000000x'){$text $count;}
            else{
    $text '&nbsp;';}
            
            if(
    $fix_value == '000000x'){$color ' color:#FFFFFF;';}
            else{
    $color '';}
            
            
    $preoutput .= '<div style="background-color:#'.$value.';'.$color.'" title="'.$value.'">'.$text.'</div>'."\n";
        }
        
    $output .= '<div class="row">'."\n".$preoutput."\n".'</div><div class="clear">&nbsp;</div>'."\n";
        
        
    $preoutput '';
        
    $count++;

    Aber Deine Variante ist viel eleganter

    Ich schick Dir das Script gerne zu wenn es fertig ist.

    Grüße

  10. #9
    Bandit
    Gast

    Standard AW: foreach-Schleife; eigenartiges Problem

    Zitat Zitat von Kemos Beitrag anzeigen
    Ich schick Dir das Script gerne zu wenn es fertig ist.
    Jau, mach' mal.

  11. #10
    Prinz(essin)
    Registriert seit
    26.03.2013
    Beiträge
    835
    Danke
    20
    Bekam 76 mal "Danke" in 75 Postings

    Standard AW: foreach-Schleife; eigenartiges Problem

    Statt des doppelten Gleichheitszeichens sollte man hier den dreifachen(===) nehmen der auch den Datentyp mit vergleicht, dann geht es auch ohne strcmp.

    siehe auch http://www.php.net/manual/de/types.comparisons.php

Ähnliche Themen

  1. foreach-Schleife zur Text-Verschlüsselung
    Von Permafrost im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 17
    Letzter Beitrag: 23.02.2011, 17:58
  2. Brauche Hilfe - Abbruch von foreach Schleife
    Von TanyaTie im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 12
    Letzter Beitrag: 26.06.2009, 20:49
  3. Problem mit Schleife in der Schleife
    Von 1234d1 im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 9
    Letzter Beitrag: 16.06.2009, 18:41
  4. foreach problem
    Von Unregistriert im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 1
    Letzter Beitrag: 05.09.2008, 23:19
  5. Foreach problem
    Von JDF1976 im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 1
    Letzter Beitrag: 17.01.2007, 20:19

Stichworte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •