hi everyone, i want to remove </li> inside following html code using str_replace function but cant remove it, and only forward slash is causing this problem. how can i overcome this forward slash issue? $my_pages='<li>test text</li>'; echo str_replace('</li>', '', $my_pages); PHP: quick help please..........
Works just fine for me, output is: <li>test text Are you sure you're not doing anything else (have you posted all the code)?
thanks for reply and also tried with above variable of test text but when i tested separately with original code it didnt replace last closing li so actual variable will contain following code <li class="page_item page-item-5"><a title="News" href="http://localhost/matinimages/?page_id=5">News</a></li> and i dont need the last </li>, which str_replace is not replacing.
Still works just the same mate, no </li>. Can you show the actual code you're using? Is the variable coming from $_POST or $_GET? Perhaps you need to remove the slashes if you have magic_quotes enabled? You should echo out the before and after string.
in actual code im setting variable from wordpress code that automatically generates the above variable for me. $my_pages = wp_list_pages('meta_key=News&meta_value=true&echo=0&title_li='); i have following code in php.ini file magic_quotes_gpc = On should other magic quotes also be on? Thanks for your time dear.
thanks a lot for your time dear............. the problem was at my end......actually i was checking output using firebug rather than from view source. firebug automatically adds closing tag each time it was removed. so i by chance saw view source and it was replacing it with empty string...... sorry for this disturbance.. but thanks again for your help.