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

[PHP] multi-dimensional arrays

2009-04-13 Thread Andres Gonzalez
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 input string can have any

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

[PHP] Multi-Dimensional Arrays

2002-10-09 Thread Jonathan Duncan
I am trying to create an array to hold shopping cart information. The array I am using is called "cartArray". What I want to do is to define a sub-array of cartArray with the information from one product. Then the next time a product is added it appends then new information as a second sub-arra

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

2002-07-09 Thread Lazor, Ed
From: Chad Day [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 09, 2002 1:22 PM To: [EMAIL PROTECTED] Subject: [PHP] multi dimensional arrays / radio buttons / mass confusion on my part Ok.. what I have is a database of first names and last names, and some other columns that don't mat

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

2002-07-09 Thread Chad Day
Ok.. what I have is a database of first names and last names, and some other columns that don't matter here. A form is presented to a user, lets them enter a bunch of names, attributes of the person, etc. After submission, each record is checked against the current database to see if the name cu

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
e through each element incrementing a counter to do so. Just use count(). It works fine on multi-dimensional arrays. Robert Zwink -Original Message- From: Brandon Orther [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 12:00 PM To: PHP User Group Subject: [PHP] Multi Dimensional Arrays

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
// then everything under the col (by row) echo "$main_menu[$j][$k]"; } } - Original Message - From: "Brandon Orther" <[EMAIL PROTECTED]> To: "PHP User Group" <[EMAIL PROTECTED]> Sent: Monday, May

[PHP] Multi Dimensional Arrays?

2001-05-07 Thread Brandon Orther
Hello, I am working on a menu script that I wanted to use multi-dimensional arrays for. Here is the conf file I have: //Main Menu Array $main_menu[0] = "Menu 1"; //Represents the name of the menu //Menu 1 Array $main_menu[0][0] = "Test 1"; $main_menu[0][1] = "Test 2"; $main_menu[0][2] = "Test