Hi everybody,
i have some data which i copied from a web page. its all option values of a select box. now im trying to find a way where i can add a coma at the end of each </option> tag.
here is my code which i took from php.net:
this is replacing each empty space with a coma not at the end of tag.
please anybody can help me to find out a way where i can do it?
i have some data which i copied from a web page. its all option values of a select box. now im trying to find a way where i can add a coma at the end of each </option> tag.
here is my code which i took from php.net:
Code:
$text = '<option value="test 1">test 1</option><option value="test 2">test 2</option>';
$text = preg_replace('/</',' <',$text);
$text = preg_replace('/>,/','> ',$text);
$desc = html_entity_decode(strip_tags($text));
$desc = preg_replace('/[\n\r\t]/',' ',$desc);
$desc = preg_replace('/ /',' ',$desc);
echo preg_replace('/[\ ]/', ',', $desc);
please anybody can help me to find out a way where i can do it?
Comment