So, I have a file script.php: <? $data1 = array("name1" => "john", "name2" => "kevin"); $data2 = array("name1" => "tom", "name2" => "irvin"); ?> Now I want to open this file like "script.php?ch=data1" and when its opened on page must be printed text "john kevin" (by <? echo $something ?>), or when I open page "script.php?ch=data2" on page is printed "tom irvin". How can I do that? (plz post an example) Please forgive me for this newb question and for my pure english.
if ( isset($_GET['ch']) && isset($$_GET['ch']) && is_array($names=$$_GET['ch']) ) { echo $names['name1'].' '.$names['name2']; } PHP: Like that?
Yes, but when I'm used this script, it printed "john kevinArray". I dont need two names together, I need to use this script like: script.php: "<? $data1 = array("name1" => "john", "name2" => "kevin"); $data2 = array("name1" => "tom", "name2" => "irvin"); ?> <html> <body> My name is <?php echo $name1; ?> (name1 from data1) My bro name is <?php echo $name2; ?> (name2 from data1) </body> </html> " So when I open script.php?ch=data1 will be printed: " My name is john My bro name is kevin " AND THANK YOU VV MUCH FOR FAST REPLY!
<?php if ( isset($_GET['ch']) && isset($$_GET['ch']) && is_array($names=$$_GET['ch']) ) { $name1=$names['name1']; $name2=$names['name2']; } ?> <html> <body> <?php echo $name1; ?> <br /><br /> <?php echo $name2; ?> </body> </html> PHP: