Welcome Guest, Not a member yet? Register   Sign In
Desires and elegant foreach for a messy array
#1

[eluser]pdxbenjamin[/eluser]
My array looks something like this...
Code:
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)

When I foreach through them I get...
Code:
1
2
3
4
5

That isn't my problem, what I have is an update running at the end of each iteration.
Code:
1
<- UPDATE
2
<- UPDATE
3
<- UPDATE
4
<- UPDATE
5
<- UPDATE

How do I make it a collective so I can format the string, and make one Update.
I'd like to have the final result. 1, 2, 3, 4, 5



Thanks.
#2

[eluser]jmadsen[/eluser]
assuming you want to build an sql IN clause?

Look at http://php.net/manual/en/function.implode.php
#3

[eluser]pdxbenjamin[/eluser]
Yes, thank you that's what I needed.




Theme © iAndrew 2016 - Forum software by © MyBB