1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

implode() error

Discussion in 'PHP' started by Derpost, Jun 21, 2011.

  1. #1
    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;
        }
    
    PHP:
    using:

    
    $return = implode('|', $this->array_implode($sonuc2));
    
    PHP:
    this error
    
    Warning:  Invalid argument supplied for foreach() in C:\AppServ\www\disavurv2\classes\arkadas.class.php on line 7
    
    PHP:
    Function's line 7
    
      foreach ($arrays as $item) {
    
    PHP:
    Help me :)
     
    Derpost, Jun 21, 2011 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Run a print_r on the original array before passing it to the method. What does it show?

    Also, I would replace

    array_implode($arrays, &$target = array())

    with

    array_implode($arrays, $target = array())

    Pass by reference is depreciated in php 5.3+
     
    jestep, Jun 21, 2011 IP
  3. Derpost

    Derpost Active Member

    Messages:
    95
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #3
    thanks for help..

    i resolve the my problem.
    my problem is $sonuc2 not array :)

    for example: var_dump()
     
    Derpost, Jun 21, 2011 IP