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
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
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
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
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
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
$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
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,
>
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
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
:[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
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
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
$
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
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
15 matches
Mail list logo