multidimensional arrays in PHP

multidimensional arrays in PHP

Post by Murray *AC » Sun, 23 Apr 2006 21:25:24


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.yqcomputer.com/ - Template Triage!
http://www.yqcomputer.com/ , Tutorials & Resources
http://www.yqcomputer.com/ - DW FAQs, Tutorials & Resources
http://www.yqcomputer.com/ (MM) Technotes
==================
 
 
 

multidimensional arrays in PHP

Post by Michael Fe » Sun, 23 Apr 2006 21:42:46

.oO(Murray *ACE*)


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


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.yqcomputer.com/

Micha

 
 
 

multidimensional arrays in PHP

Post by Murray *AC » Sun, 23 Apr 2006 21:47:54

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.yqcomputer.com/ - Template Triage!
http://www.yqcomputer.com/ , Tutorials & Resources
http://www.yqcomputer.com/ - DW FAQs, Tutorials & Resources
http://www.yqcomputer.com/ (MM) Technotes
==================
 
 
 

multidimensional arrays in PHP

Post by Murray *AC » Fri, 28 Apr 2006 23:26:05

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.yqcomputer.com/ - Template Triage!
http://www.yqcomputer.com/ , Tutorials & Resources
http://www.yqcomputer.com/ - DW FAQs, Tutorials & Resources
http://www.yqcomputer.com/ (MM) Technotes
==================