PHP count question
Get the solution ↓↓↓Solution:
Rude comment aside, I believe this is what you are trying to do:
// gets rid of empty tags,
// trims them and sets them to lowercase
for ($i=0; $i<count($tags); $i++) {
if (trim($tags[$i]) != '') { // using trim to get rid of spaces
$tags[$i] = strtolower(strip_tags($tags[$i]));
} else {
unset($tags[$i]); // gets rid of empty tags
}
}
// print out tags
switch (count($tags)) {
case 0:
echo 'no tags entered.';
break;
case 1:
echo $tags[0] . ' tag entered.';
break;
default:
echo implode(', ', $tags) . ' tags entered';
break;
}
Next time, learn to:
- Be more respectful
- Word your question properly, and give examples of expected input and output when necessary
In that order.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: using $this when not in object context
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.