Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #4093
| From | Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: implode() order? |
| Date | 2011-12-19 21:23 +0100 |
| Organization | albasani.net |
| Message-ID | <jco6gd$96e$1@news.albasani.net> (permalink) |
| References | <23705179.475.1324325630088.JavaMail.geo-discussion-forums@yqgn9> |
Mike schrieb:
> How can I specify the order that an Array() is imploded? See code below:
>
> [code]
> <?php
> $toImplode = Array(
> 1 => "Second",
> 0 => "First",
> 2 => "Third"
> );
>
> $finalString = implode(" - ", $toImplode);
>
> echo "<p>" . $finalString . "</p>";
>
> /* Results as "Second - First - Third"
> * But I need it to be "First - Second - Third"
> */
> ?>
> [/code]
Do a ksort( $toImplode ); before the implode. (See
http://de.php.net/manual/en/function.ksort.php)
Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
implode() order? Mike <mpearl1@gmail.com> - 2011-12-19 12:13 -0800
Re: implode() order? Mike <mpearl1@gmail.com> - 2011-12-19 12:15 -0800
Re: implode() order? Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2011-12-19 21:23 +0100
Re: implode() order? Mike <mpearl1@gmail.com> - 2011-12-19 12:36 -0800
Re: implode() order? Jerry Stuckle <jstucklex@attglobal.net> - 2011-12-19 16:15 -0500
Re: implode() order? Mike <mpearl1@gmail.com> - 2011-12-19 13:30 -0800
Re: implode() order? Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2011-12-19 23:47 +0100
Re: implode() order? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-20 02:59 +0100
Re: implode() order? Jerry Stuckle <jstucklex@attglobal.net> - 2011-12-19 22:34 -0500
Re: implode() order? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-20 02:55 +0100
csiph-web