note 83464 added to function.implode

From: Date: Tue, 27 May 2008 14:12:22 +0000
Subject: note 83464 added to function.implode
Groups: php.notes 
Request: Send a blank email to php-notes+get-139857@lists.php.net to get a copy of this message
A usefull version of implode() when you need to surround values, for example when you are working with nodes (HTML, XML) function myImplode($before, $after, $glue, $array){ $nbItem = count($array); $i = 1; foreach($array as $item){ if($i < $nbItem){ $output .= "$before$item$after$glue"; }else $output .= "$before$item$after"; $i++; } return $output; } $an_array = array('value1','value2'); print myImplode("<a href=\"#\">","</a>"," > ", $an_array); output : <a href="#">value1</a> > <a href="#">value2</a> ---- Server IP: 213.246.42.8 Probable Submitter: 82.127.36.207 ---- Manual Page -- http://www.php.net/manual/en/function.implode.php Edit -- https://master.php.net/note/edit/83464 Del: integrated -- https://master.php.net/note/delete/83464/integrated Del: useless -- https://master.php.net/note/delete/83464/useless Del: bad code -- https://master.php.net/note/delete/83464/bad+code Del: spam -- https://master.php.net/note/delete/83464/spam Del: non-english -- https://master.php.net/note/delete/83464/non-english Del: in docs -- https://master.php.net/note/delete/83464/in+docs Del: other reasons-- https://master.php.net/note/delete/83464 Reject -- https://master.php.net/note/reject/83464 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139857) next »