i have a really simple task to do, but i guess i`m a little bit stuck.
I have to check if post title has certain word in it and then give it a certain category. One post can have multiple categories.
How do i do it?
Switch without breaks so it checks every possible word?
switch ($title) {
case ($pos = strpos($title, 'xxx')):
$this->updatePostCategory($id, Admin_model::XXX);
case ($pos = strpos($title, 'asd')):
$this->updatePostCategory($id, Admin_model::ASD);
}
Many if statements under each other?
if (strpos($title, 'xxx')) {
$this->updatePostCategory($id, Admin_model::XXX);
}
if (strpos($title, 'asd')) {
$this->updatePostCategory($id, Admin_model::ASD);
}
What would be best practice here?
Thanks :>
Aucun commentaire:
Enregistrer un commentaire