array implode

Discussion in 'PHP' started by bugcoder, Mar 6, 2009.

  1. #1
    $arrVariable = array('TOPIC' => array ( 
    										0 => array ('ID' => 'ARTH' ), 
    										1 => array ('ID' => 'KIDS' ), 
    										2 => array ('ID' => 'PAIN' ), 
    										3 => array ('ID' => 'PRNT' ) 
    							  ) 
    			         ) ;
    PHP:
    i have the above array and my requirement is that i want to have values like arth,kids,pain,prnt in comma seprated form just like using implode. i have tried following code.

    			foreach($arrVariable as $arr){
    						foreach($arr as $ttt){
    							foreach($ttt as $k => $v){
    									 $variable .= ','.$v;
    							}
    						}
    			}
    			echo $variable;
    PHP:

    which prints ,ARTH,KIDS,PAIN,PRNT. Can someone please help me for any better logic or how to remove first comma...:confused:
     
    bugcoder, Mar 6, 2009 IP
  2. bugcoder

    bugcoder Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ohhhh how silly i am i should just use substr to remove that comma. :D

    echo $variable=substr($variable,1);

    thats it!!!!!!!!
     
    bugcoder, Mar 6, 2009 IP