-
http://php.flashwebhost.com/sherly/vegetables.php
Code:
<?php
$vegetables = array('tomato', 'potato', 'cucumber', 'carrot', 'spinach', 'cabbage', 'chilli');
echo '<pre>';
print_r($vegetables );
echo '</pre>';
echo '<p>I am going to add 2 more vegetables to $vegetables array.</p>';
$vegetables [] = 'beetroot';
$vegetables [] = 'beans';
echo '<pre>';
print_r($vegetables );
echo '</pre>';
-
Quote:
Originally Posted by
stefin
http://php.flashwebhost.com/stefin/sports.php
Code:
<?php
$sports = array('FootBall', 'Cricket', 'Hockey', 'basketball', 'Golf', 'rugby', 'Baseball');
echo $sports[0];
echo '<br>';
echo $sports[1];
echo '<br>';
echo $sports[6];
echo '<br>';
echo $sports[2];
echo '<br>';
Nice program, try other examples too.
-
Quote:
Originally Posted by
sherlyk
Why do you store friends in an array $age ?
Follow naming convention, use meaningful names for variables. Don't store friends in $enemy array, they can get attacked by mistake.
-
http://php.flashwebhost.com/mini/elements.php
Code:
<?php
$cars = array ('Ferrari', 'Ford' ,'Dodge','Honda', 'Hyundai', 'Nissan');
echo '<pre>';
print_r ($cars);
echo '<p> I am going to add to 3 more cars to $cars array. </p>';
$cars[] = 'Mercedes';
$cars[] = 'Toyota';
$cars[] = 'Tata';
echo '<pre>';
print_r ($cars);
echo '<pre>';
-
Quote:
Originally Posted by
minisoji
http://php.flashwebhost.com/mini/elements.php
Code:
<?php
$cars = array ('Ferrari', 'Ford' ,'Dodge','Honda', 'Hyundai', 'Nissan');
echo '<pre>';
print_r ($cars);
echo '<p> I am going to add to 3 more cars to $cars array. </p>';
$cars[] = 'Mercedes';
$cars[] = 'Toyota';
$cars[] = 'Tata';
echo '<pre>';
print_r ($cars);
echo '<pre>';
Good code.
-
http://php.flashwebhost.com/stefin/trees.php
Code:
<?php
$garden = array('mango tree', 'apple tree', 'cherry tree', 'Jackfruit tree', 'neem tree', 'mulberry tree', 'coconut tree');
echo '<pre>';
print_r($garden);
echo '</pre>';
echo '<p>The Gardener Is Going To Plant Four More Trees In His $garden array</p>';
$garden[] = 'bamboo tree';
$garden[] = 'rubber tree';
$garden[] = 'teak tree';
$garden[] = 'rose wood';
echo '<pre>';
print_r($garden);
echo '</pre>';
-
http://php.flashwebhost.com/stefin/animals.php
Code:
<?php
$animals = array('leapord', 'monkey', 'elephant', 'wolf', 'tiger', 'lion', 'giraffe');
$numberOfAnimals = count($animals);
echo '<p>We Have ' . $numberOfAnimals . ' Animals In Our Zoo.</p>';
-
Quote:
Originally Posted by
stefin
http://php.flashwebhost.com/stefin/trees.php
Code:
<?php
$garden = array('mango tree', 'apple tree', 'cherry tree', 'Jackfruit tree', 'neem tree', 'mulberry tree', 'coconut tree');
echo '<pre>';
print_r($garden);
echo '</pre>';
echo '<p>The Gardener Is Going To Plant Four More Trees In His $garden array</p>';
$garden[] = 'bamboo tree';
$garden[] = 'rubber tree';
$garden[] = 'teak tree';
$garden[] = 'rose wood';
echo '<pre>';
print_r($garden);
echo '</pre>';
Good code, $garden can be changed to $forest (or $trees), how can some one grow so much trees in a garden :bull_head:
Try the code with foreach.
Code:
foreach ($garden as $plant) {
echo $plant;
echo '<br>';
}
-
DAY 5 PHP PROGRAMMING
http://php.flashwebhost.com/tom/fruits.php
Code:
<?php
$mohanlalMovies = array('Mr. Fraud', 'Drishyam', 'Geethanjali', 'Red Wine', 'Ladies and Gentleman', 'Lokpal', 'Karmayodha', 'Run Baby Run', 'Spirit', 'Grandmaster', 'Casanova');
echo $mohanlalMovies [0];
echo '<br>';
echo $mohanlalMovies [1];
echo '<br>';
echo $mohanlalMovies [7];
echo '<br>';
echo $mohanlalMovies [8];
echo '<br>';
echo $mohanlalMovies [9];
-
DAY 5 PHP PROGRAMMING
http://php.flashwebhost.com/tom/array_raw.php
Code:
<?php
$mohanlalMovies = array('Mr. Fraud', 'Drishyam', 'Geethanjali', 'Red Wine', 'Ladies and Gentleman', 'Lokpal', 'Karmayodha', 'Run Baby Run', 'Spirit', 'Grandmaster', 'Casanova');
echo '<pre>';
print_r($mohanlalMovies);
echo '</pre>';
$mohanlalHitMovies = array('Drishyam', 'Narasimham', 'Aaram Thampuran', 'Spadikam', 'Thenmavin Kombathu', 'Manichithrathazhu', 'Devasuram', 'Kilukkam', 'Chithram', 'Irupatham Noottandu');
echo '<pre>';
var_dump($mohanlalHitMovies);
echo '</pre>';