-
http://php.flashwebhost.com/mini/array_2.php
Code:
<?php
$mobiles = array();
$mobile1 = array();
$mobile1 ['name'] = 'Samsung';
$mobile1 ['price'] = 4000;
$mobile1 ['color'] = 'white';
$mobile1 ['available'] = 'yes';
$mobile2 = array();
$mobile2 ['name'] = 'Reliance';
$mobile2 ['price'] = 5000;
$mobile2 ['color'] = 'yellow';
$mobile2 ['available'] = 'yes';
$mobile3 = array();
$mobile3 ['name'] = 'nokia';
$mobile3['price'] = 6000;
$mobile3 ['color'] = 'red';
$mobile3 ['available'] ='no';
$mobiles[] = $mobile1;
$mobiles[] = $mobile2;
$mobiles[] = $mobile3;
/*
echo '<pre>';
print_r($mobiles);
echo'</pre>';*/
echo '<h1>Menu</h1>';
foreach ($mobiles as $mobile) {
echo '<hr>';
echo '<b>Name:</b> ' . $mobile['name'] . '<br>';
echo '<b>Price:</b> Rs: ' . $mobile['price'] . '/-<br>';
echo '<b>Color:</b> ' . $mobile['color'] . '<br>';
echo '<b>Available:</b> ' . $mobile['available'] . '<br>';
if ($mobile ['available'] == 'yes') {
echo '<p>Product in stock, buy before it becomes out of stock.</p>';
}
if ($mobile ['available'] == 'no'){echo '<p>Out of Stock.</P>';}
}
echo'<hr>';
-
Quote:
Originally Posted by
minisoji
http://php.flashwebhost.com/mini/array_2.php
Code:
<?php
$mobiles = array();
$mobile1 = array();
$mobile1 ['name'] = 'Samsung';
$mobile1 ['price'] = 4000;
$mobile1 ['color'] = 'white';
$mobile1 ['available'] = 'yes';
$mobile2 = array();
$mobile2 ['name'] = 'Reliance';
$mobile2 ['price'] = 5000;
$mobile2 ['color'] = 'yellow';
$mobile2 ['available'] = 'yes';
$mobile3 = array();
$mobile3 ['name'] = 'nokia';
$mobile3['price'] = 6000;
$mobile3 ['color'] = 'red';
$mobile3 ['available'] ='no';
$mobiles[] = $mobile1;
$mobiles[] = $mobile2;
$mobiles[] = $mobile3;
/*
echo '<pre>';
print_r($mobiles);
echo'</pre>';*/
echo '<h1>Menu</h1>';
foreach ($mobiles as $mobile) {
echo '<hr>';
echo '<b>Name:</b> ' . $mobile['name'] . '<br>';
echo '<b>Price:</b> Rs: ' . $mobile['price'] . '/-<br>';
echo '<b>Color:</b> ' . $mobile['color'] . '<br>';
echo '<b>Available:</b> ' . $mobile['available'] . '<br>';
if ($mobile ['available'] == 'yes') {
echo '<p>Product in stock, buy before it becomes out of stock.</p>';
}
if ($mobile ['available'] == 'no'){echo '<p>Out of Stock.</P>';}
}
echo'<hr>';
Good script.
-
http://php.flashwebhost.com/austin/array2.php
Code:
<?php
$stnds = array();
$std1 = array();
$std1['name'] = 'CHRIS';
$std1['age'] = 9;
$std1['mark'] = 87;
$std1['place'] = 'ARTHUNKAL';
$std2=array();
$std2['name'] = 'Stefin';
$std2['age']= 13;
$std2['mark']= 91;
$std2['place']= 'ERNAKULAM';
$stnds[]=$std1;
$stnds[]=$std2;
echo '<pre>';
print_r($stnds);
echo'</pre>';
foreach($stnds as $std){
echo strtoupper($std['name']);
if($std['age']>10){
echo '<br>'.'hello big boy <br>';}
else{
echo'<br>'.'hello small boy<br>';}
if($std['mark']>50)
echo 'You passed';
else
echo 'Am sorry you have to try again';
echo '<br>'.strtolower($std['place']);
echo '<br><br>';
}
-
DAY 6 PHP PROGRAMMING - MY 1'st CODE
http://php.flashwebhost.com/ramesh/day-6/day-6_1.php
PHP Code:
<?php
$teamindia = array();
$playername['name'] = 'Sourav Ganguly';
$playername['price'] = 90000000;
$playername['iconic player'] = 'yes';
$playername['formats of cricket'] = 'Twenty20';
$playername['team'] = 'Kolkata Knight Riders';
$playername['player type'] = 'Batsman';
echo '<pre>';
print_r($playername);
echo '</pre>';
echo ('<font color=green><h1>About the IPL player</h1></font>');
echo '<b>Name:</b> ' . $playername['name'] . '<br>';
echo '<b>Price Paid:</b> Rs: ' . $playername['price'] . '/-<br>';
echo '<b>Team:</b> ' . $playername['team'] . '<br>';
echo '<b>Player Type:</b> ' . $playername['player type'] . '<br>';
echo '<b>Iconic Player:</b> ' . $playername['iconic player'] . '<br>';
echo '<b>Formats of Cricket:</b> ' . $playername['formats of cricket'] . '<br>';
-
http://php.flashwebhost.com/vineesh/..._6_array_1.php
PHP Code:
<?php
$domainName = array();
$domainName[extension] = '.com';
$domainName[registry] = 'public domain registry';
$domainName[price] = '$10.50 per year';
$domainName[status] = 'congratulations!, its available!!!';
$registrar = '<a href="http://www.FlashWebHost.com">www.flashwebhost.com</a> <br><br>';
echo '<pre>';
print_r($domainName);
echo '</pre>';
echo '<h1><font color=red><i>Domain Name Info: </i></h1></font>';
echo '<b><font color=green>Extension: </b></font>' . strtoupper($domainName[extension]) . '<br>';
echo '<b><font color=blue>Registry: </b></font>'. ucwords($domainName[registry]) . '<br>';
echo '<b><font color=magenta>Current Status: </b></font> ' . ucwords($domainName[status]) . '<br>';
echo '<b><font color=orange>Price: </b></font>' . ucwords($domainName[price]) . '<br><br>';
echo '<font color=green>' . 'This means, ' . strtoupper($domainName[extension]) . ' extension domain is providing by ' . ucwords($domainName[registry]) . ' And the cost is ' . ucwords($domainName[price]) . 'You can register domain names through ' . strtoupper($registrar) .
'</font>';
-
http://php.flashwebhost.com/vineesh/..._6_array_2.php
PHP Code:
<?php
$timeTables = array();
$timeTable1 = array();
$timeTable1[day] = 'monday';
$timeTable1[teacher] = 'murali';
$timeTable1[subject] = 'english';
$timeTable1[period] = 'first period';
$timeTable1[availability] = 'present';
$timeTable2 = array();
$timeTable2[day] = 'tuesday';
$timeTable2[teacher] = 'chandrika';
$timeTable2[subject] = 'chemistry';
$timeTable2[period] = 'second period';
$timeTable2[availability] = 'present';
$timeTable3 = array();
$timeTable3[day] = 'wednesday';
$timeTable3[teacher] = 'alice';
$timeTable3[subject] = 'biology';
$timeTable3[period] = 'third period';
$timeTable3[availability] = 'absent';
$timeTables[] = $timeTable1;
$timeTables[] = $timeTable2;
$timeTables[] = $timeTable3;
echo '<h2><font=color:red;>Class info: </font> </h2>';
foreach ($timeTables as $timeTable) {
echo '<b> <font color=blue>Day: </font></b>' . ucwords($timeTable[day]) . '<br>';
echo '<b> <font color=blue>Name of the Teacher: </font></b>' . ucwords($timeTable[teacher]) . '<br>';
echo '<b> <font color=blue>Subject:</font></b> ' . ucwords($timeTable[subject]) . '<br>';
echo '<b> <font color=blue>Period: </font></b> ' . ucwords($timeTable[period]) . '<br>';
if ($timeTable[availability] == 'present') {
echo '<p>Students, teacher is on the way, you may go to your classes.</p>';
} if ($timeTable[availability] == 'absent') {
echo '<p>Heyy.. teacher is absent today, you may go home :) </p>';
}
}
-
http://php.flashwebhost.com/ramesh/day-6/day-6_2.php
PHP Code:
<?php
$teams = array();
$team_KingsXIPunjab = array();
$team_KingsXIPunjab['team'] = 'KingsXIPunjab';
$team_KingsXIPunjab['player_name'] = 'Sewang';
$team_KingsXIPunjab['price'] = 3000000;
$team_KingsXIPunjab['batsman'] = 'yes';
$team_KingsXIPunjab['spin bowler'] = 'yes';
$team_KingsXIPunjab['wicket keepper'] = 'no';
$team_DelhiDaredevils = array();
$team_DelhiDaredevils['team'] = 'Delhi Daredevils';
$team_DelhiDaredevils['player_name'] = 'Kevin Peterson';
$team_DelhiDaredevils['price'] = 9000000;
$team_DelhiDaredevils['batsman'] = 'yes';
$team_DelhiDaredevils['spin bowler'] = 'no';
$team_DelhiDaredevils['wicket keepper'] = 'yes';
$team_ChennaiSuperKings = array();
$team_ChennaiSuperKings['team'] = 'Chennai Super Kings';
$team_ChennaiSuperKings['player_name'] = 'Dhoni';
$team_ChennaiSuperKings['price'] = 1000000;
$team_ChennaiSuperKings['batsman'] = 'yes';
$team_ChennaiSuperKings['spin bowler'] = 'no';
$team_ChennaiSuperKings['wicket keepper'] = 'yes';
$teams[] = $team_KingsXIPunjab;
$teams[] = $team_DelhiDaredevils;
$teams[] = $team_ChennaiSuperKings;
echo '<h1>I P L TEAMS</h1>';
foreach ($teams as $team) {
echo '<hr>';
echo '<b>Team:</b> ' . $team['team'] . '<br>';
echo '<b>Name:</b> ' . $team['player_name'] . '<br>';
echo '<b>Price:</b> Rs: ' . $team['price'] . '/-<br>';
echo '<b>batsman:</b> ' . $team['batsman'] . '<br>';
echo '<b>spin bowler:</b> ' . $team['spin bowler'] . '<br>';
echo '<b>wicket keepper:</b> ' . $team['wicket keepper'] . '<br>';
if ($team['spin bowler'] == 'yes') {
echo '';
}
}
echo '<hr>';