Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

multidimensional arrays in PHP

LEGEND ,
Apr 22, 2006 Apr 22, 2006
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
==================



TOPICS
Server side applications
381
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 22, 2006 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 22, 2006 Apr 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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 27, 2006 Apr 27, 2006
LATEST
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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines