note 64423 deleted from function.implode by nlopess

From: Date: Fri, 14 Apr 2006 11:48:08 +0000
Subject: note 64423 deleted from function.implode by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108054@lists.php.net to get a copy of this message
Note Submitter: wladston at gmail dot com ---- #this is my first post to the php.net site! :) #implementing Hotmail resident Tree2054 function with presets #I don't know of any more presets, I just use querystring and mysql ... :( function implode_with_options($assoc_array, $preset = '', $prefix = '', $k_v_glue = '', $vwrap = '', $seperator = ''){ if($preset == 'sql'){$prefix = ""; $k_v_glue = "="; $vwrap = "'"; $seperator = ", ";} if($preset == 'qst'){$prefix = "?"; $k_v_glue = "="; $vwrap = ""; $seperator = "&";} foreach ($assoc_array as $k => $v){ $tmp[] = $k . $k_v_glue . $vwrap . $v . $vwrap; } return $prefix . implode($seperator, $tmp); } $items = array('Apples', 'number' => 3, 'Vehicle' => ''); #For a query string: echo implode_with_options($items, 'qst'); #Produces # ?0=Apples&number=3&Vehicle= #For a SQL query echo implode_with_options($items, 'sql'); #Produces # 0="Apples", number="3", Vehicle=""

« previous php.notes (#108054) next »