开发者

PHP array minor problem

开发者 https://www.devze.com 2023-02-12 07:37 出处:网络
I\'m really not sure how to expl开发者_如何学JAVAain this. It\'s so simple I can\'t fathom why it\'s not working.

I'm really not sure how to expl开发者_如何学JAVAain this. It's so simple I can't fathom why it's not working.

I have a loop. It puts a bunch of strings into an array. If I fill a single variable with any given string, it will output it perfectly.

But filling an array with the strings will make it give me the dreaded:

Array Array Array Array Array Array Array Array

Note: my strings are not all 'Array'.

The way I loop is:

 while(...)
 {
     $arr[] = $resultFromLoop;
 }

Here is my var_dump.

    array(1) {
      ["tagName"]=>
      string(5) "magic"
    }
    array(1) {
      ["tagName"]=>
      string(4) "nunu"
    }
    array(1) {
      ["tagName"]=>
      string(5) "books"
    }
    array(1) {
      ["tagName"]=>
      string(0) ""
    }
    array(1) {
      ["tagName"]=>
      string(3) "zzz"
    }
    array(1) {
      ["tagName"]=>
      string(4) "grey"
    }
    array(1) {
      ["tagName"]=>
      string(3) "new"
    }
    array(1) {
      ["tagName"]=>
      string(6) "flight"
    }


This is because you're working with array as with a string.

It puts a bunch of strings into an array.

Nope, there are no strings. I already gave you a magic var_dump($resultFromLoop) function, but you're too lazy to use it for debugging your code (because there is SO, where you can ask any question and don't bother yourself with thinking)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号