Welchen Wert hat ein leeres Arrayfeld?

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

  • Welchen Wert hat ein leeres Arrayfeld?

    Hallo,

    ich hab es mal etwas abgekürzt:

    PHP Code:
    $bla explode("/",""); 
    Bei dieser Anwendung mit explode() kommt natürlich nichts Sinnvolles heraus, ich möchte aber gern wissen wie man checkt ob $bla[0] einen Wert hat oder nicht. Besetzt wird das Feld des Arrays ja mit irgendwas...

    Die 3 Varianten bringen jedenfalls kein Ergebnis:

    PHP Code:
    if($bla[0]==""){...}
    if(
    $bla[0]==NULL){...}
    if(!isset(
    $bla[0])){...}
    if(empty(
    $bla[0])){...} 

  • #2
    was verrät print_r?

    Comment


    • #3
      PHP Code:
      Array ( [0] => ) 

      Comment


      • #4
        vardump() verrät mehr:
        Code:
        array(1) {
           [0]=>  string(0) ""
        }
        Die Regeln | rtfm | register_globals | strings | SQL-Injections | [COLOR=silver][[/COLOR][COLOR=royalblue]–[/COLOR][COLOR=silver]][/COLOR]

        Comment


        • #5
          Warum geht dann if($bla[0]==""){...} nicht?

          Comment


          • #6
            Funktioniert wunderbar:
            PHP Code:
            if ( $blubb ] == '' ) {
               echo 
            '1';
            }
            if ( 
            $blubb ] === '' ) {
               echo 
            '2';
            // Ausgabe: 12 
            Die Regeln | rtfm | register_globals | strings | SQL-Injections | [COLOR=silver][[/COLOR][COLOR=royalblue]–[/COLOR][COLOR=silver]][/COLOR]

            Comment


            • #7
              array explode ( string $delimiter, string $string [, int $limit] )
              ...
              If delimiter contains a value that is not contained in string, then explode() will return an array containing string.
              Wenn bei dir $bla[0] == '' nicht wahr wird, dann war dein $string nicht ''.
              Last edited by onemorenerd; 13-07-2007, 01:32.

              Comment

              Working...
              X