RE: [PHP] arrays and php

2003-09-30 Thread Chris W. Parker
Angelo Zanetti mailto:[EMAIL PROTECTED]
on Tuesday, September 30, 2003 5:43 AM said:

 hi I have a table with rows and each row contains a checkbox ( array)
 and a record. TD of the checkbox:
 echo(td width=15 bgcolor=#9FD9FFinput type=checkbox name=chkR[]
 value=. $chkSessionF[$i] ./td);

Firstly you should be putting double quotes around every value in your
HTML tags.

Revised: (watch wrap)

echo td width=\15\ bgcolor=\#9FD9FF\input type=\checkbox\
name=\chkR[]\ value=\{$chkSessionF[$i]}\/td;

I also changed

. $chkSessionF[$i] .

into

{$chkSessionF[$i]}

.

You can do it either way. I prefer the latter.

If you're not sure what a value is use print_r() to determine it.

echo pre;
print_r($chk);
echo /pre;

Quick side note on the above code:

You cannot write it like:

echo pre.print_r($chk)./pre;

It will not work.

 can anyone help. this is very strange.

I think your problem may just be the quotes around the values in the
HTML. Give it a shot.



hth,
chris.

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



Re: [PHP] arrays and php

2003-09-30 Thread Jason Wong
On Wednesday 01 October 2003 00:10, Chris W. Parker wrote:

[snip]

 If you're not sure what a value is use print_r() to determine it.

 echo pre;
 print_r($chk);
 echo /pre;

 Quick side note on the above code:

 You cannot write it like:

 echo pre.print_r($chk)./pre;

 It will not work.

You can do this though:

  echo pre, print_r($chk), /pre;

Or if using a recent version of php:

  echo nl2br(print_r($var, 1)); //or something like that

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
No bird soars too high if he soars with his own wings.
-- William Blake
*/

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



RE: [PHP] arrays and php

2003-09-30 Thread Chris W. Parker
Jason Wong mailto:[EMAIL PROTECTED]
on Tuesday, September 30, 2003 11:06 AM said:

 echo pre.print_r($chk)./pre;
 
 It will not work.
 
 You can do this though:
 
   echo pre, print_r($chk), /pre;

Well heck, that makes things easier!

What's the difference between using , or . for concatenation? (I thought
they were the same.)



Chris.

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



Re: [PHP] arrays and php

2003-09-30 Thread Jason Wong
On Wednesday 01 October 2003 02:14, Chris W. Parker wrote:
 Jason Wong mailto:[EMAIL PROTECTED]

 on Tuesday, September 30, 2003 11:06 AM said:
  echo pre.print_r($chk)./pre;
 
  It will not work.

Actually, the above *does* work!

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Test-tube babies shouldn't throw stones.
*/

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



Re: [PHP] arrays and php

2003-09-30 Thread CPT John W. Holmes
From: Chris W. Parker [EMAIL PROTECTED]

 echo pre.print_r($chk)./pre;

 It will not work.

 You can do this though:

   echo pre, print_r($chk), /pre;

Well heck, that makes things easier!

What's the difference between using , or . for concatenation? (I thought
they were the same.)

Using a comma is just like using another echo command. So for the above,
you're effectively saying:

echo pre; echo print_r($chk); echo /pre;

Note that print_r() will (by default) return a 1 (TRUE) upon success, so you
end up with a 1 being printed at the end of your data.

You could also use this method:

echo pre.print_r($chk,TRUE)./pre;

The TRUE causes the output of print_r() to be returned instead of printed
automatically. The benefit to this method is that you don't end up with the
1 being printed.

---John Holmes...

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



Re: [PHP] arrays and php

2003-09-30 Thread CPT John W. Holmes
From: Jason Wong [EMAIL PROTECTED]
 On Wednesday 01 October 2003 02:14, Chris W. Parker wrote:
  Jason Wong mailto:[EMAIL PROTECTED]
 
  on Tuesday, September 30, 2003 11:06 AM said:
   echo pre.print_r($chk)./pre;
  
   It will not work.
 
 Actually, the above *does* work!

It depends on how you define works :)

You'll end up with output like this:

Array
(
[0] = one
[1] = two
[2] = three
)
pre1/pre

which works but is not what was desired. 

---John Holmes...

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



RE: [PHP] arrays and php

2003-09-30 Thread Chris W. Parker
Jason Wong mailto:[EMAIL PROTECTED]
on Tuesday, September 30, 2003 11:27 AM said:

 echo pre.print_r($chk)./pre;
 
 It will not work.
 
 Actually, the above *does* work!

Not for me. (Although we may be testing different things.)

?

$pageTitle = Checkout Step One;

echo pre.print_r($pageTitle)./pre;
?

Gives me:

Checkout Step Onepre1/pre


If I use the , it's a little closer but still not correct (at least not
what I want). With , I get:

preCheckout Step One1/pre

Close but I don't know where the one is coming from. Maybe it's saying
it's 'true'?



Chris.

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



RE: [PHP] arrays and php

2003-09-30 Thread Chris W. Parker
CPT John W. Holmes mailto:[EMAIL PROTECTED]
on Tuesday, September 30, 2003 11:32 AM said:

 Note that print_r() will (by default) return a 1 (TRUE) upon success,
 so you end up with a 1 being printed at the end of your data.

[snip]

That answers it!




c.

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



RE: [PHP] arrays and php

2003-09-30 Thread Chris Shiflett
--- Chris W. Parker [EMAIL PROTECTED] wrote:
 What's the difference between using , or . for concatenation? (I
 thought they were the same.)

The comma isn't concatenation; echo can take multiple arguments.

I've heard statements about passing multiple arguments to echo being faster
than using concatenation, but every benchmark I've tried myself shows them to
be nearly identical. Feel free to try it yourself and post your results. :-)
I'd be curious to see if others reach the same conclusion.

Chris

=
HTTP Developer's Handbook
 http://shiflett.org/books/http-developers-handbook
My Blog
 http://shiflett.org/

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



Re: [PHP] arrays and php

2003-09-30 Thread CPT John W. Holmes
From: Chris W. Parker [EMAIL PROTECTED]
 CPT John W. Holmes mailto:[EMAIL PROTECTED]
 on Tuesday, September 30, 2003 11:32 AM said:

  Note that print_r() will (by default) return a 1 (TRUE) upon success,
  so you end up with a 1 being printed at the end of your data.

 [snip]

 That answers it!

See... if you'd only have waited that extra second to press the Send button!
;)

---John Holmes...

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



RE: [PHP] arrays and php

2003-09-30 Thread Chris W. Parker
Chris Shiflett mailto:[EMAIL PROTECTED]
on Tuesday, September 30, 2003 11:39 AM said:

 The comma isn't concatenation; echo can take multiple arguments.

Oh ok, I get it.

 I've heard statements about passing multiple arguments to echo being
 faster than using concatenation, but every benchmark I've tried
 myself shows them to be nearly identical. Feel free to try it
 yourself and post your results. :-) I'd be curious to see if others
 reach the same conclusion. 

I tried this, and I think the comma was just slightly faster than the
period. But then again I didn't always get consistent results because I
was trying this out on a machine that is not very fast so the speed at
which is processes something varies quite a bit.

My conclusion was that it's not fast enough to bother changing all my
code, or start writing in a new way.


Although during some testing I did find that writing loops in the
following way is faster than normal.

$counter = -1;
while(++$counter  $amount)
{
// do stuff
}

It made a big enough difference on my slow machine to merit me writing
as many loops in this way as I can. (I think.)



Chris.

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



Re: [PHP] arrays and php

2003-09-30 Thread Jason Wong
On Wednesday 01 October 2003 02:32, Chris W. Parker wrote:
 Jason Wong mailto:[EMAIL PROTECTED]

 on Tuesday, September 30, 2003 11:27 AM said:
  echo pre.print_r($chk)./pre;
 
  It will not work.
 
  Actually, the above *does* work!

 Not for me. (Although we may be testing different things.)

Sorry you're right, it doesn't work. I was testing with php-cli using:

  echo (pre . print_r($_SERVER) . pre);

there was no parse error and I saw some output fly off the console, so I 
thought it had worked :)

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
You can't fall off the floor.
*/

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



Re: [PHP] arrays and php

2003-09-30 Thread Eugene Lee
On Tue, Sep 30, 2003 at 09:10:44AM -0700, Chris W. Parker wrote:
: 
: Angelo Zanetti mailto:[EMAIL PROTECTED]
: on Tuesday, September 30, 2003 5:43 AM said:
: 
:  hi I have a table with rows and each row contains a checkbox ( array)
:  and a record. TD of the checkbox:
:  echo(td width=15 bgcolor=#9FD9FFinput type=checkbox name=chkR[]
:  value=. $chkSessionF[$i] ./td);
: 
: Firstly you should be putting double quotes around every value in your
: HTML tags.
: 
: Revised: (watch wrap)
: 
: echo td width=\15\ bgcolor=\#9FD9FF\input type=\checkbox\
: name=\chkR[]\ value=\{$chkSessionF[$i]}\/td;

A heredoc is more readable:

echo HTMLTAG
td width=15 bgcolor=#9FD9FFinput type=checkbox name=chkR[]
value={$chkSessionF[$i]}/td
HTMLTAG;

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



RE: [PHP] arrays and php

2003-09-30 Thread Chris W. Parker
Eugene Lee mailto:[EMAIL PROTECTED]
on Tuesday, September 30, 2003 2:12 PM said:

 A heredoc is more readable:
 
 echo HTMLTAG
 td width=15 bgcolor=#9FD9FFinput type=checkbox name=chkR[]
 value={$chkSessionF[$i]}/td
 HTMLTAG;

Yeah, but I don't like those. :P


chris.

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