Skip to main content
Inspiring
April 22, 2006
Question

multidimensional arrays in PHP

  • April 22, 2006
  • 3 replies
  • 406 views
How can I do an array assignment like this -

$variable[1,1]='foo';

???

I want to have multiple sets of prompts, allowing multi-language pages,
e.g.,

$prompt[1,1] = 'hello';
$prompt[2,1]='ola';

etc.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



This topic has been closed for replies.

3 replies

Inspiring
April 27, 2006
Micha:

Without that gettext addon, how can I parse the language from a page to
determine which prompts to use?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Michael Fesser" <netizen@gmx.de> wrote in message
news:lu8k42t9mdo9fgrf6n036ics888poeu1jr@4ax.com...
> .oO(Murray *ACE*)
>
>>How can I do an array assignment like this -
>>
>>$variable[1,1]='foo';
>
> $variable[1][1] = 'foo';
>
>>I want to have multiple sets of prompts, allowing multi-language pages,
>>e.g.,
>>
>>$prompt[1,1] = 'hello';
>>$prompt[2,1]='ola';
>
> For such things I use language codes instead of just numbers:
>
> $prompt['de-DE'][1] = 'hallo';
> $prompt['en-GB'][1] = 'hello';
> $prompt['es-ES'][1] = 'ola';
>
> Or vice versa:
>
> $prompt[1]['de-DE'] = 'hallo';
> $prompt[1]['en-GB'] = 'hello';
> $prompt[1]['es-ES'] = 'ola';
>
> Other syntax:
>
> $prompt[1] = array(
> 'de-DE' => 'hallo',
> 'en-GB' => 'hello',
> 'es-ES' => 'ola'
> );
>
> In my scripts the current page language is stored in a variable $lang
> for example, which can then also be used for the 'html' element:
>
> <html lang="<?php print $lang?>">
>
> Just an idea.
>
> I also recommend to have a look at the gettext extension, which can make
> localization and i18n much easier:
>
> http://www.php.net/manual/en/ref.gettext.php
>
> Micha


Inspiring
April 22, 2006
Awesome - that's what I wanted, Micha! Thanks....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Michael Fesser" <netizen@gmx.de> wrote in message
news:lu8k42t9mdo9fgrf6n036ics888poeu1jr@4ax.com...
> .oO(Murray *ACE*)
>
>>How can I do an array assignment like this -
>>
>>$variable[1,1]='foo';
>
> $variable[1][1] = 'foo';
>
>>I want to have multiple sets of prompts, allowing multi-language pages,
>>e.g.,
>>
>>$prompt[1,1] = 'hello';
>>$prompt[2,1]='ola';
>
> For such things I use language codes instead of just numbers:
>
> $prompt['de-DE'][1] = 'hallo';
> $prompt['en-GB'][1] = 'hello';
> $prompt['es-ES'][1] = 'ola';
>
> Or vice versa:
>
> $prompt[1]['de-DE'] = 'hallo';
> $prompt[1]['en-GB'] = 'hello';
> $prompt[1]['es-ES'] = 'ola';
>
> Other syntax:
>
> $prompt[1] = array(
> 'de-DE' => 'hallo',
> 'en-GB' => 'hello',
> 'es-ES' => 'ola'
> );
>
> In my scripts the current page language is stored in a variable $lang
> for example, which can then also be used for the 'html' element:
>
> <html lang="<?php print $lang?>">
>
> Just an idea.
>
> I also recommend to have a look at the gettext extension, which can make
> localization and i18n much easier:
>
> http://www.php.net/manual/en/ref.gettext.php
>
> Micha


Inspiring
April 22, 2006
.oO(Murray *ACE*)

>How can I do an array assignment like this -
>
>$variable[1,1]='foo';

$variable[1][1] = 'foo';

>I want to have multiple sets of prompts, allowing multi-language pages,
>e.g.,
>
>$prompt[1,1] = 'hello';
>$prompt[2,1]='ola';

For such things I use language codes instead of just numbers:

$prompt['de-DE'][1] = 'hallo';
$prompt['en-GB'][1] = 'hello';
$prompt['es-ES'][1] = 'ola';

Or vice versa:

$prompt[1]['de-DE'] = 'hallo';
$prompt[1]['en-GB'] = 'hello';
$prompt[1]['es-ES'] = 'ola';

Other syntax:

$prompt[1] = array(
'de-DE' => 'hallo',
'en-GB' => 'hello',
'es-ES' => 'ola'
);

In my scripts the current page language is stored in a variable $lang
for example, which can then also be used for the 'html' element:

<html lang="<?php print $lang?>">

Just an idea.

I also recommend to have a look at the gettext extension, which can make
localization and i18n much easier:

http://www.php.net/manual/en/ref.gettext.php

Micha