Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi 
 
In the book on page 57 it states in the tips "Because PHP is lax with its variable
structures, an array can even use a combination of numbers and strings as its keys. The only important rule is that the keys of an array must each be unique."
 
How can you get duplicate keys? 
 
I tried experimenting wrote the following:

 

<?php
echo "<p>This text was generated by PHP!</p>";
echo "hello word<br>";
$states['IL'] = "hellow";
$states['IM'] = "IM hellow";
$states['IM'] = "IM hellow2";
echo $states['IL'];
echo "<br>";
echo $states['IM'];
echo "<br>";
echo "Test this: {$states['IM']}";
?>

 

It simply assigns the new value to the array and not let me create a duplicate?

Link to comment
Share on other sites

Thank again 

 

Sorry for asking too many questions ... I am enjoying it ... I started learning a while ago then stopped and now started again this time not to quit ... I realised alot of things I simply glossed over ... or didt type out all the code nor experimented much with the code ... this time round I am doing that and its alot more fun and I am enjoying it ... 

 

I think by being curious and trying out different things giving me more confidence to write my own little snippets ... 

Link to comment
Share on other sites

 Share

×
×
  • Create New...