You are here: Re: FUSK! « All PHP « IT news, forums, messages
Re: FUSK!

Posted by Norman Peelman on 01/10/07 01:06

"Onideus Mad Hatter" <usenet@backwater-productions.net> wrote in message
news:dfn6q25mhhkts44htptacnu5rmkbcnrq3p@4ax.com...
> In PHP...how you do you have a variable, array variable?
>
> Like I have an array called $line_1 all the way through $line_192
>
> And so I want to have a while statement where I've got like:
>
> $i = 1
> $pos = 5
>
> And then do it like $line_$i[$pos]
>
> Cept it doesn't work. Neither does $line_[$i][$pos] or
> $line_($i)[$pos] or $line_'$i[$pos]' or any of the other combinations
> and variations I've tried.
>
> In Actionscript everything has a kind of address and I can do it like:
>
> 'line_'+i+'[pos]'
>
> or
>
> line_[i][pos]
>
> But it won't work in PHP. Maybe it's just not possible in PHP? Or
> maybe there's another way of creating like an array inside an array?
>
> *confused*
>
> --
>
> Onideus Mad Hatter
> mhm Ή x Ή
> http://www.backwater-productions.net
> http://www.backwater-productions.net/hatter-blog
>



You can create and use variable array variables easily like so:


${"line_$i"}[$pos] = "some text";

and to make multi-dimensional, just:

${"line_$i"}[$pos] = array('one' => array(), 'two' => array());

and more:

${"line_$i"}[$pos]['one'][0] = array();

etc.

Norm
--
FREE Avatar hosting at www.easyavatar.com

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация