I have a text box in the admin area for entering the names of categories. Right now, this is what is in it
events homepage
Just like that above. Two categories separated by a space. So now I am trying to get the categories from the database and that is done this way. (I am using SMOF framework)
echo $data['exclude_categories'];
If I do the above, it will echo out
events homepage
So then I am trying to get a - sign and a comma placed between each category like so
//looping through my key to get the values
$string = explode(" ", $data['exclude_categories'] );
foreach($string as $cat) {
//concatenating my values into one string
$string .= '-' .$cat.",";
}
echo $data['exclude_categories']; //for testing purposes
//trimming the trailing comma from the string
$string = substr($string, 0, -1); // Delete the last character
My problem is that I get this "Array-events,-homepage" and I don't know why the Array is there