i want to use implode function for exploded veriables.
i am using this function but i want to use in my class.

public function array_implode($arrays, &$target = array()) {
        foreach ($arrays as $item) {
            if (is_array($item)) {
                $this->array_implode($item, $target);
            } else {
                $target[] = $item;
            }
        }
        return $target;
    }

using:

$return = implode('|', $this->array_implode($sonuc2));

this error

Warning:  Invalid argument supplied for foreach() in C:\AppServ\www\disavurv2\classes\arkadas.class.php on line 7

Function's line 7

  foreach ($arrays as $item) {

Help me 🙂

    The error has nothing to do with implode(). As the error message clearly states, it's the foreach() loop that is failing. The only reason you would be giving it an "invalid argument" is if you weren't giving it an array. Therefore, you should look at the argument you're passing it (which turns out to be $sonuc2) and figure out what it is ([man]var_dump/man will help in doing that).

      in a sense require use var_dump function?
      where?

        very thanks bradgrafelman i resolve the problem..
        $sonuc2 is a not array 😃

          Write a Reply...