RE: Imploding an array?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, your code will do this:

if delete[7] == 1, you will print_r($order_index[7]) which contains ???

Now from what you say $order_index[7] == "2627";

That's just weird.  Whatever it is you are doing is bad.

Regardless, you could do this:
$foo = preg_split("//",$order_index[7]);

Now $foo is an array of [0]=>2, [1]=>6, [2]=>2, [3]=>7;

Now you do a while loop:

for ($x=0;$x<=count($foo);$x++) {
  if (is_odd($x)) { $next = 1; } else { $next = 0; }
  $str .= $foo[$x];
  if ($next) $str .= ",";
  $x++;
}

Or something like that. is_odd may not be a function, but YOU figure out
how to determine if a number is odd.

Peter


On Wed, 6 Nov 2002, Aaron Wolski wrote:

> Ok...
>
> This is the code I have setup:
>
> for ($i=0;$i<sizeof($order_index);$i++) {
>
> 			if ($delete[$i] == 1) {
>
> 				print_r($order_index[$i]);
>
>
> 				$str = implode(",",$order_index[$i]);
> 				echo $str;
>
> 			}
>
> 		}
>
> Now..upon the print_r.. The values that ARE there look like      2627
> (which is order_index 26 and 27).
>
> Basically I am trying to get the 2627 into a string that looks like:
> $str = "26,27"; so I can use it in something else.
>
> *shrugs*
>
> I think I wma way off base here *eyes blurry* heeh
>
> Aaron
>
> > -----Original Message-----
> > From: Rasmus Lerdorf [mailto:rasmus@php.net]
> > Sent: Wednesday, November 06, 2002 2:16 PM
> > To: Aaron Wolski
> > Cc: php-db@lists.php.net
> > Subject: Re:  Imploding an array?
> >
> >
> > You sure you want [$i] on that?  Is it a 2-dimensional array?
> >
> > On Wed, 6 Nov 2002, Aaron Wolski wrote:
> >
> > > Hey all,
> > >
> > > Can't seem to figure out why this won't work:
> > >
> > > $test = implode(",", $order_index[$i]);
> > >
> > > When I print_r() the variable I have values so I know that works.
> > >
> > > Any thoughts on this?
> > >
> > > Thanks.
> > >
> > > Aaron
> > >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---------------------------------------------------------------------------
Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux