FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » implode() order?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: implode() order? [message #176296 is a reply to message #176294] Mon, 19 December 2011 20:23 Go to previous messageGo to previous message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma:
Senior Member
Mike schrieb:
> How can I specify the order that an Array() is imploded? See code below:
>
>
[/color]
[color=blue]>  <?php[/color]
[color=blue]>  $toImplode = Array([/color]
[color=blue]>  	1 => "Second", [/color]
[color=blue]>  	0 => "First", [/color]
[color=blue]>  	2 => "Third"[/color]
[color=blue]>  );[/color]
[color=blue]>  [/color]
[color=blue]>  $finalString = implode(" - ", $toImplode);[/color]
[color=blue]>  [/color]
[color=blue]>  echo "<p>" . $finalString . "</p>";[/color]
[color=blue]>  [/color]
[color=blue]>  /* Results as "Second - First - Third"[/color]
[color=blue]>   * But I need it to be "First - Second - Third"[/color]
[color=blue]>   */[/color]
[color=blue]>  ?>[/color]
[color=blue]>  
[/color]

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)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: implode() order?
Next Topic: FastCGI + ignore_user_abort
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 13:41:24 GMT 2024

Total time taken to generate the page: 0.05222 seconds