Originally Posted by
sherlyk
http://php.flashwebhost.com/sherly/states1.php
Code:
<?php
$states = array('Kerala' , 'Tamil Nadu' , 'Karnataka' , 'Rajastan' , 'Orissa' );
$numberOfStates = count($states);
echo '<pre>';
print_r($states);
echo '<p> I travelled to add 2 more states to $states array. </p>';
$states[] = 'Kerala';
$states[] = 'Tamil Nadu';
echo '<pre>';
print_r ($states);
echo '</pre>';
Modified your code like below. Try to create meaningfull sentences.
Your are not using the count(); function. Then no need to add in your script. Right ?
PHP Code:
<?php
$states = array('Kerala' , 'Tamil Nadu' , 'Karnataka' , 'Rajastan' , 'Orissa' );
$numberOfStates = count($states);
echo '<pre>';
print_r($states);
echo '<pre>';
echo $numberOfStates . ' States are listed here.I am going to add 2 more states ' ;
$states[] = 'Gujarat';
$states[] = 'Maharashtra';
echo '<pre>';
print_r ($states);
echo '</pre>';
echo 'So the total no of states ' . $numberOfStates;
Bookmarks