Hey CoderDan,
Your code is perfect and has helped me a lot on my website. I am stuck again with another small issue.
My script is using something like $cityname to pull city names from database.
I tried using it inside this code like this.
<?php
// use just an array.
$titles_array = array(
1 => 'car accessories $cityname', // the id integer, then the => then the value. it can be in single or double quotes, and even be another variable or capture the result of a function call
2 => ' buy sell in $cityname', // you can keep adding them all day long, just copy the line, set the number, and modify the description
3 => 'For Sale $cityname', // this is usually the kind of data one would store in a database
);
// then just spit out the entry you want:
echo $titles_array[$xsubcatid]; // of course, if there is no entry for this index ($xsubcatid) then a warning will be thrown, as it would have in your previous code, but odds are you'll never even notice that.
?>
but the code is spitting out
car accessories $cityname instead of 'car accessories NewYork'. $cityname is already a part of my script and i do understand to the a level that because I have declared it inside a new array, its not pulling the information from my DB. Is there a work around for this if you follow me?
I appreciate your time.
Thanks
Dave