Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Multi Dimension Array
Dear all,

I have a question about multi-dimension array in PHP

$m = 2;
$def = "Hello";
$abc[$m] = $def;
print "$abc[$m] \n";

This works and gives "Hello" as output.

However, if I do this:
$n = 3;
$m = 2;
$def = "Hello";
$ghi[$m][$n] = $def;
print "$ghi[$m][$n] \n";

This gives me something strange, like "Array[2]" as output,
but not "Hello".

How can this be rectified to print out "Hello" as stored in
$ghi[2][3] in this case?

Thanks,
LaBird (Benny).
[Email: Please drop all numerals for the real email address.]



Report this thread to moderator Post Follow-up to this message
Old Post
LaBird
06-03-05 08:55 AM


Re: Multi Dimension Array
"LaBird" <wlcheung@hkucs1975.org> wrote in message
news:d7omdh$65h$1@webinfo.cs.hku.hk...
> Dear all,
>
> I have a question about multi-dimension array in PHP
>
> $m = 2;
> $def = "Hello";
> $abc[$m] = $def;
> print "$abc[$m] \n";
>
> This works and gives "Hello" as output.
>
> However, if I do this:
> $n = 3;
> $m = 2;
> $def = "Hello";
> $ghi[$m][$n] = $def;
> print "$ghi[$m][$n] \n";
>


print "{$ghi[$m][$n]} \n";

php is good at interpreting what you mean, but it's not perfect. Sometimes
you gotta help it, like by surrounding a multidimensional array reference by
{} parenthesis when it's inside of a string.

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com



Report this thread to moderator Post Follow-up to this message
Old Post
Kimmo Laine
06-03-05 08:55 AM


Re: Multi Dimension Array
LaBird schrieb:
> Dear all,
>
> I have a question about multi-dimension array in PHP
>
> $m = 2;
> $def = "Hello";
> $abc[$m] = $def;
> print "$abc[$m] \n";
>
> This works and gives "Hello" as output.
>
> However, if I do this:
> $n = 3;
> $m = 2;
> $def = "Hello";
> $ghi[$m][$n] = $def;
> print "$ghi[$m][$n] \n";
>
> This gives me something strange, like "Array[2]" as output,
> but not "Hello".
>
> How can this be rectified to print out "Hello" as stored in
> $ghi[2][3] in this case?
>
> Thanks,
> LaBird (Benny).
> [Email: Please drop all numerals for the real email address.]
>
>
Hello,
if you want to use array variables in strings try these alternatives:
print "{$ghi[$m][$n]} \n";
or
print $ghi[$m][$n]." \n";

cu Tobias

Report this thread to moderator Post Follow-up to this message
Old Post
tobi
06-03-05 08:55 AM


Re: Multi Dimension Array
Thanks a lot!

Best Regards,
Benny (LaBird).

"tobi" <tobias_g@arcor.de> ???
 news:429fecd0$0$14736$9b4e6d93@newsread4
.arcor-online.net ???...
> LaBird schrieb: 
> Hello,
> if you want to use array variables in strings try these alternatives:
> print "{$ghi[$m][$n]} \n";
> or
> print $ghi[$m][$n]." \n";
>
> cu Tobias



Report this thread to moderator Post Follow-up to this message
Old Post
LaBird
06-04-05 01:55 AM


Re: Multi Dimension Array
Hi Kimmo,

Thanks a lot!

Best Regards,
Benny (LaBird).

"Kimmo Laine" <eternal.erectionN05P@Mgmail.com> ¦b¶l¥ó
news:_ZRne.1994$u74.941@reader1.news.jippii.net ¤¤¼¶¼g...
> print "{$ghi[$m][$n]} \n";
>
> php is good at interpreting what you mean, but it's not perfect. Sometimes
> you gotta help it, like by surrounding a multidimensional array reference
by
> {} parenthesis when it's inside of a string.
>
> --
> Welcome to Usenet! Please leave tolerance, understanding
> and intelligence at the door. They aren't welcome here.
> eternal piste erection miuku gmail piste com
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
LaBird
06-04-05 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:48 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.