Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

how to keep index structure when imploding an array?
Hi,

Thanks for looking/anwsering my question.

Implode seems to implode on the 'sequence' of the inputed information, not
on the array index. Is there a short command for doing that ?

For example:
$test[0]=0;
$test[1]=1;
$test[2]=2;
$test[6]=6;
$test[3]=3;
$test[4]=4;
$test[5]=5;

echo implode(",", $test);
will return 0,1,2,6,3,4,5

while I want 0,1,2,3,4,5,6

I can solve this by making a 'fake' new array and implode that, but that
doesn't look nice code to me.
for ($i=0;$i<6;$i++)
$test_sorted[$i] = $test[$i];

echo implode(",", $test_sorted);
will now return 0,1,2,3,4,5,6


Thanks in advanced,

Niels Laurens



Report this thread to moderator Post Follow-up to this message
Old Post
Niels Laurens
03-27-04 04:13 AM


Re: how to keep index structure when imploding an array?
Niels Laurens a écrit le 26/03/2004 :
> echo implode(",", $test);
> will return 0,1,2,6,3,4,5
>
> while I want 0,1,2,3,4,5,6

Use sort($test); before the implode();



Report this thread to moderator Post Follow-up to this message
Old Post
Jedi121
03-27-04 04:13 AM


Re: how to keep index structure when imploding an array?
Thanks :)
"Jedi121" <jedi121news@free.fr.Removethis> wrote in message
news:mesnews.d55a7d43.55a599ed.627.2689@free.fr.Removethis...
> Niels Laurens a écrit le 26/03/2004 : 
>
> Use sort($test); before the implode();
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Niels Laurens
03-28-04 04:53 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:58 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.