[PHP] Re: Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
At 11:06 AM +1100 12/24/08, Clancy wrote: On Tue, 23 Dec 2008 10:25:13 -0500, tedd.sperl...@gmail.com (tedd) wrote: >Two things: 1. One statement, one line. 2. The code between the two examples is different; produces different results; and thus is rather pointless in making a definitive >comparison. Spoken like a true demagogue -- nitpicking about trivial points of style, but displaying total ignorance of elementary rules of programming. Clancy: A tag strong, but you're right. Apology offered. Certainly, my comment about "One statement, one line" is a personal choice. But it is founded on 40+ years of writing code. It's something that makes debugging simpler for me and perhaps for others. My second point was just plain wrong. In one of the previous post on this thread, someone used the value of $i as an index and it produced different results. So I jumped to the conclusion it was different, but it's not. I should of examined it more closely. Sorry. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
On Tue, 23 Dec 2008 10:25:13 -0500, tedd.sperl...@gmail.com (tedd) wrote: >At 9:10 AM +1100 12/23/08, Clancy wrote: >>Schlossnagle (in "Advanced PHP Programming") advises: >> >>$i = 0; while ($i < $j) >> { >> >> ++$i; >> } >> >>rather than: >> >>$i = 0; while ($i < $j) >> { >> ... >> $i++; >> } >> >>as the former apparently uses less memory references. However I >>find it very hard to > >Two things: > >1. One statement, one line. >2. The code between the two examples is different; produces different >results; and thus is rather pointless in making a definitive >comparison. > >Assignment, demonstrate a correct way to test ++i vs i++. > >Cheers, > >tedd Spoken like a true demagogue -- nitpicking about trivial points of style, but displaying total ignorance of elementary rules of programming. One of the things I like about Schlossnagle's book is that he gives commonsense advice. Specifically he advises against obsessing about other people's style rules, but suggests that you choose a style that you like, and use it consistently. And as the examples are written they do exactly the same thing; they each go through the empty loop $j times. I had rashly assumed that anyone reading this discussion group would understand that they were shorthand for something like the following: $i = 0; while ($i < $j) { If ($a[$i]) { [ some operation involving $i] } $i++; } $i cannot be incremented at the start as it is used inside the conditional expression, nor can it be implemented inside the expression or you would get an infinite loop the first time you missed it, so it has to be incremented at the end of the loop, and it is immaterial whether you choose ++$i; or $i++; Clancy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
At 9:10 AM +1100 12/23/08, Clancy wrote: Schlossnagle (in "Advanced PHP Programming") advises: $i = 0; while ($i < $j) { ++$i; } rather than: $i = 0; while ($i < $j) { ... $i++; } as the former apparently uses less memory references. However I find it very hard to Two things: 1. One statement, one line. 2. The code between the two examples is different; produces different results; and thus is rather pointless in making a definitive comparison. Assignment, demonstrate a correct way to test ++i vs i++. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
On Mon, 22 Dec 2008 22:40:58 -0800, larstor...@gmail.com ("Lars Torben Wilson") wrote: >Well, in all fairness, it *is* faster--but you'll only notice the >difference in extremely tight and long-running loops (try it ;) ). As >long as you know why you're using it and what the side effects are, it >would be fine. But as an optimization tool, I'd agree that it's pretty >much pointless. > >It's good to remember the Rules of Optimization: > >#1) Don't. >#2) (For experts only) Don't do it yet. I like that! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
oops, yes of course lol Tim-Hinnerk Heuer http://www.ihostnz.com On Tue, Dec 23, 2008 at 7:43 PM, Lars Torben Wilson wrote: > 2008/12/22 German Geek : > > agree, ++$i wont save u nething, it just means that the variable is > > incremented after it is used: > > You meant ". . .before it is used:", right? > > > Torben > > > $i = 0; > > while ($i < 4) echo $i++; > > > > will output > > 0123 > > > > while > > > > $i = 0; > > while ($i < 4) echo ++$i; > > > > will output > > 1234 > > > > Tim-Hinnerk Heuer > > > > http://www.ihostnz.com > > > > > > On Tue, Dec 23, 2008 at 7:25 PM, Nathan Nobbe >wrote: > > > >> On Mon, Dec 22, 2008 at 3:10 PM, Clancy wrote: > >> > >> > On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: > >> > > >> > >I'd call this a micro-optimization. If changing this causes that much > of > >> > >a difference in your script, wow - you're way ahead of the rest of > us. > >> > > >> > Schlossnagle (in "Advanced PHP Programming") advises: > >> > > >> > $i = 0; while ($i < $j) > >> >{ > >> > > >> >++$i; > >> >} > >> > > >> > rather than: > >> > > >> > $i = 0; while ($i < $j) > >> >{ > >> >... > >> >$i++; > >> >} > >> > > >> > as the former apparently uses less memory references. However I find > it > >> > very hard to > >> > believe that the difference would ever show up in the real world. > >> > >> > >> nonsense, some college kid is going to put ++$i on a test to try an > impress > >> the professor when the semantics call for $i++ :D > >> > >> -nathan > >> p.s. > >> in case you couldnt tell; been there, done that. lol > >> > > > > > > -- > Torben Wilson >
Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
On Mon, Dec 22, 2008 at 11:43 PM, Lars Torben Wilson wrote: > 2008/12/22 German Geek : > > agree, ++$i wont save u nething, it just means that the variable is > > incremented after it is used: > > You meant ". . .before it is used:", right? i hope so, coming from an individual who likes to optimize, like i did on my tests during college :D http://www.php.net/manual/en/language.operators.increment.php -nathan
Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
2008/12/22 German Geek : > agree, ++$i wont save u nething, it just means that the variable is > incremented after it is used: You meant ". . .before it is used:", right? Torben > $i = 0; > while ($i < 4) echo $i++; > > will output > 0123 > > while > > $i = 0; > while ($i < 4) echo ++$i; > > will output > 1234 > > Tim-Hinnerk Heuer > > http://www.ihostnz.com > > > On Tue, Dec 23, 2008 at 7:25 PM, Nathan Nobbe wrote: > >> On Mon, Dec 22, 2008 at 3:10 PM, Clancy wrote: >> >> > On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: >> > >> > >I'd call this a micro-optimization. If changing this causes that much of >> > >a difference in your script, wow - you're way ahead of the rest of us. >> > >> > Schlossnagle (in "Advanced PHP Programming") advises: >> > >> > $i = 0; while ($i < $j) >> >{ >> > >> >++$i; >> >} >> > >> > rather than: >> > >> > $i = 0; while ($i < $j) >> >{ >> >... >> >$i++; >> >} >> > >> > as the former apparently uses less memory references. However I find it >> > very hard to >> > believe that the difference would ever show up in the real world. >> >> >> nonsense, some college kid is going to put ++$i on a test to try an impress >> the professor when the semantics call for $i++ :D >> >> -nathan >> p.s. >> in case you couldnt tell; been there, done that. lol >> > -- Torben Wilson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
2008/12/22 Nathan Nobbe : > On Mon, Dec 22, 2008 at 3:10 PM, Clancy wrote: > >> On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: >> >> >I'd call this a micro-optimization. If changing this causes that much of >> >a difference in your script, wow - you're way ahead of the rest of us. >> >> Schlossnagle (in "Advanced PHP Programming") advises: >> >> $i = 0; while ($i < $j) >>{ >> >>++$i; >>} >> >> rather than: >> >> $i = 0; while ($i < $j) >>{ >>... >>$i++; >>} >> >> as the former apparently uses less memory references. However I find it >> very hard to >> believe that the difference would ever show up in the real world. > > > nonsense, some college kid is going to put ++$i on a test to try an impress > the professor when the semantics call for $i++ :D > > -nathan > p.s. > in case you couldnt tell; been there, done that. lol Well, in all fairness, it *is* faster--but you'll only notice the difference in extremely tight and long-running loops (try it ;) ). As long as you know why you're using it and what the side effects are, it would be fine. But as an optimization tool, I'd agree that it's pretty much pointless. It's good to remember the Rules of Optimization: #1) Don't. #2) (For experts only) Don't do it yet. Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
agree, ++$i wont save u nething, it just means that the variable is incremented after it is used: $i = 0; while ($i < 4) echo $i++; will output 0123 while $i = 0; while ($i < 4) echo ++$i; will output 1234 Tim-Hinnerk Heuer http://www.ihostnz.com On Tue, Dec 23, 2008 at 7:25 PM, Nathan Nobbe wrote: > On Mon, Dec 22, 2008 at 3:10 PM, Clancy wrote: > > > On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: > > > > >I'd call this a micro-optimization. If changing this causes that much of > > >a difference in your script, wow - you're way ahead of the rest of us. > > > > Schlossnagle (in "Advanced PHP Programming") advises: > > > > $i = 0; while ($i < $j) > >{ > > > >++$i; > >} > > > > rather than: > > > > $i = 0; while ($i < $j) > >{ > >... > >$i++; > >} > > > > as the former apparently uses less memory references. However I find it > > very hard to > > believe that the difference would ever show up in the real world. > > > nonsense, some college kid is going to put ++$i on a test to try an impress > the professor when the semantics call for $i++ :D > > -nathan > p.s. > in case you couldnt tell; been there, done that. lol >
Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)
On Mon, Dec 22, 2008 at 3:10 PM, Clancy wrote: > On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: > > >I'd call this a micro-optimization. If changing this causes that much of > >a difference in your script, wow - you're way ahead of the rest of us. > > Schlossnagle (in "Advanced PHP Programming") advises: > > $i = 0; while ($i < $j) >{ > >++$i; >} > > rather than: > > $i = 0; while ($i < $j) >{ >... >$i++; >} > > as the former apparently uses less memory references. However I find it > very hard to > believe that the difference would ever show up in the real world. nonsense, some college kid is going to put ++$i on a test to try an impress the professor when the semantics call for $i++ :D -nathan p.s. in case you couldnt tell; been there, done that. lol
[PHP] More microptimisation (Was Re: [PHP] Variable as an index)
On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: >I'd call this a micro-optimization. If changing this causes that much of >a difference in your script, wow - you're way ahead of the rest of us. Schlossnagle (in "Advanced PHP Programming") advises: $i = 0; while ($i < $j) { ++$i; } rather than: $i = 0; while ($i < $j) { ... $i++; } as the former apparently uses less memory references. However I find it very hard to believe that the difference would ever show up in the real world. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
MikeP schreef: > Hello, > I am trying to output the value of the following:($x is an int incremented > by a for statement. > echo " > >'$users[$x][U]' > "; > > I have tried putting the quotes all over and all I get is: > 'Array[U]'. > > What am I doing wrong. you need to help php understand your 'complex' interpolated var (and I'm assuming the key U is not a constant, so ...: e.g.: echo " foo {$users[$x]['U']} bar "; I wouldn't worry about performance overhead of interpolation as opposed to string concatenation ... fixing and/or caching of the DB query (from which I assume your generating the $users array), if you have a performance issue, will win you orders of magnitude more performance than any string interpolation micro-optimization you might undertake. > Thanks > Mike > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
2008/12/21 German Geek : > Yes, i agree with this. Even if it takes a few nano seconds more to write > out more understandable code, it's worth doing it because code management is > more important than sqeezing out the last nano second. And then also an > $var = "Hello"; > echo "$val World"; > > has less characters than and is more readable than > > $var = "Hello"; > echo $var ." World"; > > So it would take maybe a few nano seconds less to read it from the hard > drive. And we all know that disk I/O is more expensive than pushing around > variables in main memory in terms of time. And RAM is soo cheap these days. > > Tim-Hinnerk Heuer > > http://www.ihostnz.com Agreed. Although I tend to use ' instead of " unless I need interpolation, if I feel it's really going to make that much of a difference then I start looking at rewriting that section in C or refactoring. String interpolation shouldn't be a bottleneck. Getting back to the original question though, the correct way to express a multidimensional array access inside a string is to use curly braces, and include quotes around any string index names: echo "An array: {$arr[$foo]['bar']}\n"; Torben > On Mon, Dec 22, 2008 at 12:50 PM, Anthony Gentile wrote: > >> True, it might mean the very slightest in milliseconds...depending on what >> you're doing/hardware. However, no harm in understanding the difference/how >> it works. >> Many will code echo "Hello World" and echo 'Hello World'; and never know >> the >> difference, I just happen to think being aware of the details will help for >> the long term programmer. >> Since, I brought it up, I'll go ahead and give another example. Ternaries >> that make a lot of people feel awesome because a lot is being accomplished >> in one line are also more opcodes than their if-else statement >> equivalents...and often times can be more confusing to future maintainers >> of >> the code. >> >> Anthony Gentile >> >> >> >> On Sun, Dec 21, 2008 at 6:20 PM, Chris wrote: >> >> > Anthony Gentile wrote: >> > >> >> for e.g. >> >> $var = 'world'; >> >> echo "hello $var"; >> >> vs >> >> echo 'hello '.$var; >> >> >> >> The first uses twice as many opcodes as compared to the second. The >> first >> >> is >> >> init a string and adding to it the first part(string) and then the >> second >> >> part (var); once completed it can echo it out. The second is simply two >> >> opcodes, a concatenate and an echo. Interpolation. >> >> >> > >> > I'd call this a micro-optimization. If changing this causes that much of >> a >> > difference in your script, wow - you're way ahead of the rest of us. >> > >> > >> > >> http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html >> > >> > http://www.phpbench.com/ >> > >> > -- >> > Postgresql & php tutorials >> > http://www.designmagick.com/ >> > >> > >> > -- Torben Wilson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
Yes, i agree with this. Even if it takes a few nano seconds more to write out more understandable code, it's worth doing it because code management is more important than sqeezing out the last nano second. And then also an $var = "Hello"; echo "$val World"; has less characters than and is more readable than $var = "Hello"; echo $var ." World"; So it would take maybe a few nano seconds less to read it from the hard drive. And we all know that disk I/O is more expensive than pushing around variables in main memory in terms of time. And RAM is soo cheap these days. Tim-Hinnerk Heuer http://www.ihostnz.com On Mon, Dec 22, 2008 at 12:50 PM, Anthony Gentile wrote: > True, it might mean the very slightest in milliseconds...depending on what > you're doing/hardware. However, no harm in understanding the difference/how > it works. > Many will code echo "Hello World" and echo 'Hello World'; and never know > the > difference, I just happen to think being aware of the details will help for > the long term programmer. > Since, I brought it up, I'll go ahead and give another example. Ternaries > that make a lot of people feel awesome because a lot is being accomplished > in one line are also more opcodes than their if-else statement > equivalents...and often times can be more confusing to future maintainers > of > the code. > > Anthony Gentile > > > > On Sun, Dec 21, 2008 at 6:20 PM, Chris wrote: > > > Anthony Gentile wrote: > > > >> for e.g. > >> $var = 'world'; > >> echo "hello $var"; > >> vs > >> echo 'hello '.$var; > >> > >> The first uses twice as many opcodes as compared to the second. The > first > >> is > >> init a string and adding to it the first part(string) and then the > second > >> part (var); once completed it can echo it out. The second is simply two > >> opcodes, a concatenate and an echo. Interpolation. > >> > > > > I'd call this a micro-optimization. If changing this causes that much of > a > > difference in your script, wow - you're way ahead of the rest of us. > > > > > > > http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html > > > > http://www.phpbench.com/ > > > > -- > > Postgresql & php tutorials > > http://www.designmagick.com/ > > > > >
Re: [PHP] Variable as an index
Anthony Gentile wrote: for e.g. $var = 'world'; echo "hello $var"; vs echo 'hello '.$var; The first uses twice as many opcodes as compared to the second. The first is init a string and adding to it the first part(string) and then the second part (var); once completed it can echo it out. The second is simply two opcodes, a concatenate and an echo. Interpolation. I'd call this a micro-optimization. If changing this causes that much of a difference in your script, wow - you're way ahead of the rest of us. http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html http://www.phpbench.com/ -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
Anthony Gentile wrote: True, it might mean the very slightest in milliseconds...depending on what you're doing/hardware. Connecting to a db will (probably) take longer than most of those differences, let alone running a query & processing the results. Ternaries that make a lot of people feel awesome because a lot is being accomplished in one line are also more opcodes than their if-else statement equivalents...and often times can be more confusing to future maintainers of the code. I dislike ternaries for their over-use - I've seen nested ternaries and it's taken me 10 mins to read the code.. *shudder*. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
True, it might mean the very slightest in milliseconds...depending on what you're doing/hardware. However, no harm in understanding the difference/how it works. Many will code echo "Hello World" and echo 'Hello World'; and never know the difference, I just happen to think being aware of the details will help for the long term programmer. Since, I brought it up, I'll go ahead and give another example. Ternaries that make a lot of people feel awesome because a lot is being accomplished in one line are also more opcodes than their if-else statement equivalents...and often times can be more confusing to future maintainers of the code. Anthony Gentile On Sun, Dec 21, 2008 at 6:20 PM, Chris wrote: > Anthony Gentile wrote: > >> for e.g. >> $var = 'world'; >> echo "hello $var"; >> vs >> echo 'hello '.$var; >> >> The first uses twice as many opcodes as compared to the second. The first >> is >> init a string and adding to it the first part(string) and then the second >> part (var); once completed it can echo it out. The second is simply two >> opcodes, a concatenate and an echo. Interpolation. >> > > I'd call this a micro-optimization. If changing this causes that much of a > difference in your script, wow - you're way ahead of the rest of us. > > > http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html > > http://www.phpbench.com/ > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > >
Re: [PHP] Variable as an index
for e.g. $var = 'world'; echo "hello $var"; vs echo 'hello '.$var; The first uses twice as many opcodes as compared to the second. The first is init a string and adding to it the first part(string) and then the second part (var); once completed it can echo it out. The second is simply two opcodes, a concatenate and an echo. Interpolation. Anthony Gentile On Sun, Dec 21, 2008 at 5:47 PM, German Geek wrote: > OK. I would think it uses more memory then, but doubt it would be slower. > Isnt the output buffered in memory anyway though in PHP? Surely the buffer > is bigger than 100 bytes (which is about the length of this string). So one > way or the other, the memory is used. > > Tim-Hinnerk Heuer > > http://www.ihostnz.com > > > On Mon, Dec 22, 2008 at 11:12 AM, Marc Steinert wrote: > > > German Geek schrieb: > > > >> Why is the first method faster and uses less memory? > >> > >> > >> > > Because the concatenation operator first reassembles a new string, stores > > it in memory then passes this newly created string to the echo function, > if > > I'm not misstaken. > > > > > > -- > > http://bithub.net/ > > Synchronize and share your files over the web for free > > > > >
Re: [PHP] Variable as an index
German Geek schrieb: Why is the first method faster and uses less memory? Because the concatenation operator first reassembles a new string, stores it in memory then passes this newly created string to the echo function, if I'm not misstaken. -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
Why is the first method faster and uses less memory? Tim-Hinnerk Heuer http://www.ihostnz.com On Mon, Dec 22, 2008 at 10:59 AM, Marc Steinert wrote: > MikeP schrieb: > >> I have tried putting the quotes all over and all I get is: >> 'Array[U]'. >> >> >> > Try to avoid accessing the two-dimensional array $users inside a string. > Use echo's ability to accept multiple parameters: > > echo '', $users[$x]['U'], ''; > > Or by concating the string with the .-Operator: > > echo ''.$users[$x]['U'].''; > > The first method is faster and needs less memory. > > -- > http://bithub.net/ > Synchronize and share your files over the web for free > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Variable as an index
OK. I would think it uses more memory then, but doubt it would be slower. Isnt the output buffered in memory anyway though in PHP? Surely the buffer is bigger than 100 bytes (which is about the length of this string). So one way or the other, the memory is used. Tim-Hinnerk Heuer http://www.ihostnz.com On Mon, Dec 22, 2008 at 11:12 AM, Marc Steinert wrote: > German Geek schrieb: > >> Why is the first method faster and uses less memory? >> >> >> > Because the concatenation operator first reassembles a new string, stores > it in memory then passes this newly created string to the echo function, if > I'm not misstaken. > > > -- > http://bithub.net/ > Synchronize and share your files over the web for free > >
Re: [PHP] Variable as an index
$users is an array and you are trying to simply put it in a string. $x seems to be undefined ergo it's not printing anything. If 'U' is the index in the array for your variable, use the '.' operator to concatenate strings: echo " '" . $users[$x]['U'] ."' "; Tim-Hinnerk Heuer http://www.ihostnz.com On Mon, Dec 22, 2008 at 10:44 AM, MikeP wrote: > Hello, > I am trying to output the value of the following:($x is an int incremented > by a for statement. >echo " > > '$users[$x][U]' >"; > > I have tried putting the quotes all over and all I get is: > 'Array[U]'. > > What am I doing wrong. > Thanks > Mike > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Variable as an index
MikeP schrieb: I have tried putting the quotes all over and all I get is: 'Array[U]'. Try to avoid accessing the two-dimensional array $users inside a string. Use echo's ability to accept multiple parameters: echo '', $users[$x]['U'], ''; Or by concating the string with the .-Operator: echo ''.$users[$x]['U'].''; The first method is faster and needs less memory. -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php