/    Sign up×
Community /Pin to ProfileBookmark

algo–>php

can anybody please provide me help by converting the following algorithm to php

$nameofcountry={‘usa’, ‘uk’, ‘japan’, ‘germany’, ‘australia’}
$nameofcapital={‘london’, ‘washinton’, ‘sydney’, ‘melbourne’}
for(i=1;i<=no of items in the array $nameofcountry;i++){
if($card== ith item of $nameofcontry){
$bed==ith item of $nameofcapital
}
}

Also can anybody tell me how to do the following work

there is link ‘index.php?pno=5’
there is link ‘index.php?pno=6’
there is link ‘index.php?pno=7’

in the index.php there is a code

……………
……………..
switch(‘pno’)
case ‘5’:
include ‘test.php’;
…………..
…………
i want to pass the value of the variable ‘pno’ to the other link test.php
like test.php?pno=value of pno in the link index.php

how to do these two work????
can anybody tell me plese.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYApr 30.2006 — not sure if that's what you want:
[code=php]
<?php
$countries = array("usa", "uk", "japan", "germany", "australia");
$capital = array("washington", "london", "tokyo", "berlin", "sydney");

foreach($countries as $key => $country){
if($card == $key){
# careful: = not == (you want to assign the value, not to compare it)
$bed = $capital[$key];
}
}
?>
[/code]


for the other question:
[code=php]
<?php
if(!empty($_GET['pno'])){
$pno = $_GET['pno'];
}else{
# default
$pno = "5";
}
switch($pno){
case "5":
include "test.php?pno=$pno";
break;
}
?>
[/code]
Copy linkTweet thisAlerts:
@roxanauthorMay 01.2006 — The first code is not working.

actually my old code was

[code=php]
<?php
switch ('$_GET['page'])
case 'index':
include 'index.htm';
break;
case 'test':
include 'test.htm';
break;
....
....
?>
[/code]


so what i did was

$ram=array("index","test",...................);

$sita=array("index.htm","test.htm",.................);

foreach($ram as $key => $ram){

if(isset($_GET['page']) == $key){

include $sita[$key];

}

}

but it is displaying more than 5 pages.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMay 01.2006 — do you just want to append the extension?
×

Success!

Help @roxan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...