php - To replace two pieces of text do I need to do str_replace twice? -


is there better function i'm doing? need rid of both <div> , </div> if in strings. i'm doing this. works, seems ugly me:

$cdshtml .= str_replace('</div>','', str_replace('<div>', '', sprintf('<p><strong>%s</strong><br>%s<br>%s</p>', $cd->name, $cd->description, $cd->prereq))); 

is there 1 function replace both of str_replace?

you can replace more 1 string pass array of values first parameter in str_replace

$cdshtml .= str_replace(array('</div>','<div>'),'',  sprintf('<p><strong>%s</strong><br>%s<br>%s</p>', $cd->name, $cd->description, $cd->prereq)); 

Comments