Re: [PHP] multi-dimensional arrays

2009-04-14 Thread Jim Lucas
Andres Gonzalez wrote: Hi, I am learning PHP and have a simple question. I have a input string in this form: xxx xx x xx xxx xx x x xxx xx xx . . . xx xxx xx xx xx each line has 6 words of various lengths, all separated by white space. the in

Re: [PHP] multi-dimensional arrays

2009-04-13 Thread Michael A. Peters
Nitsan Bin-Nun wrote: $string = "xxx xx x xx xxx xxx xx x xx xxx"; $t = explode("\n", $string); foreach ($t as $k => $v) $t[$k] = explode(" ", $v); var_dump($t); After assigning the string do $string = preg_replace('/\s+/',' ',$string); Then you should be able to

Re: [PHP] multi-dimensional arrays

2009-04-13 Thread Nitsan Bin-Nun
Just wondering, there is callback version of preg_match_all() ? if so you could have done it in one line I think.. On Mon, Apr 13, 2009 at 9:52 PM, Andres Gonzalez wrote: > I was having the same problem. The second way was what I was looking for. > > Thank you so much for your help--I did not kno

Re: [PHP] multi-dimensional arrays

2009-04-13 Thread Andres Gonzalez
I was having the same problem. The second way was what I was looking for. Thank you so much for your help--I did not know about preg_match_all(). very coolthanks again. -Andres Shawn McKenzie wrote: Shawn McKenzie wrote: Well in your approach you get a bunch of empty elements where t

Re: [PHP] multi-dimensional arrays

2009-04-13 Thread Shawn McKenzie
Shawn McKenzie wrote: > Well in your approach you get a bunch of empty elements where the spaces > are. Here are two ways but I'm sure one preg_match_all() without the > explodes and loop could do it (some guru will show us): > > //one way > $text = 'xxx xx x xx xxx > xx x x

Re: [PHP] multi-dimensional arrays

2009-04-13 Thread Shawn McKenzie
Nitsan Bin-Nun wrote: > $string = "xxx xx x xx xxx > xxx xx x xx xxx"; > $t = explode("\n", $string); > foreach ($t as $k => $v) $t[$k] = explode(" ", $v); > var_dump($t); > > On Mon, Apr 13, 2009 at 8:55 PM, Andres Gonzalez > wrote: > >> Hi, >> >> I am learning PHP

Re: [PHP] multi-dimensional arrays

2009-04-13 Thread Nitsan Bin-Nun
$string = "xxx xx x xx xxx xxx xx x xx xxx"; $t = explode("\n", $string); foreach ($t as $k => $v) $t[$k] = explode(" ", $v); var_dump($t); On Mon, Apr 13, 2009 at 8:55 PM, Andres Gonzalez wrote: > Hi, > > I am learning PHP and have a simple question. > I have a inpu

Re: [PHP] Multi-Dimensional Arrays

2002-10-10 Thread Jonathan Duncan
Yeah, you rock, that works great. Not to mention you have a great name. Jonathan Duncan "Jonathan Sharp" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > try doing this for each item: > > $cartArray[] = array('itemnumber' => $itemnumber, 'brand' => $brand, >

Re: [PHP] Multi-Dimensional Arrays

2002-10-09 Thread Jonathan Sharp
try doing this for each item: $cartArray[] = array('itemnumber' => $itemnumber, 'brand' => $brand, 'quantity' => $itemqty, 'name' => $itemname); -js Jonathan Duncan wrote: > I am trying to create an array to hold shopping cart information. The array > I am using is called "cartArray". What I

RE: [PHP] multi dimensional arrays / radio buttons / mass confusion on my part

2002-07-09 Thread Lazor, Ed
It sounds like you're trying to do too many things at once. If you create a form to accept entries, process the entries when the form is submitted. Check each entry and only add ones that don't already exist in the database. After that, if you want to display results, start at the beginning of th

RE: [PHP] Multi Dimensional Arrays?

2001-05-15 Thread Robert V. Zwink
:[EMAIL PROTECTED]] Sent: Tuesday, May 15, 2001 10:55 AM To: Robert V. Zwink; PHP User Group Subject: RE: [PHP] Multi Dimensional Arrays? Anyone knows how to determine how many levels has an array? TIA Rom -Original Message- From: Robert V. Zwink [mailto:[EMAIL PROTECTED]] Sent: Tuesday

RE: [PHP] Multi Dimensional Arrays?

2001-05-15 Thread Romulo Roberto Pereira
Anyone knows how to determine how many levels has an array? TIA Rom -Original Message- From: Robert V. Zwink [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 15, 2001 10:30 AM To: Brandon Orther; PHP User Group Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Multi Dimensional Arrays? You are

RE: [PHP] Multi Dimensional Arrays?

2001-05-15 Thread Robert V. Zwink
You are on the right track but doing something wrong: You are correctly assigning a string to an array: //Main Menu Array $main_menu[0] = "Menu 1"; //Represents the name of the menu But then you are taking that string one character at a time and replacing it with invalid data: //Menu 1 Array $

RE: [PHP] Multi Dimensional Arrays?

2001-05-08 Thread Tim Ward
PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: 07 May 2001 18:12 > To: Brandon Orther; PHP User Group > Subject: Re: [PHP] Multi Dimensional Arrays? > > > I would have to say you would need a nested for loop to count > your array. > > $j = 0 ; > $k = 0 ; > > for

Re: [PHP] Multi Dimensional Arrays?

2001-05-07 Thread tcuhost
I would have to say you would need a nested for loop to count your array. $j = 0 ; $k = 0 ; for ( ; $j != '' ) ; $j++ ) { //top of the col. echo "$main_menu[$j][$k]"; for ( $k = 1; $k != '' ; $k++ ) { // then everything