jesushax Posted June 16, 2008 Share Posted June 16, 2008 hi here is my function problem is it outputs nothing, just blank :S anyone know why? Thanks function paragraphs($data) { strip_tags($data, "<p>"); if(substr($data, 0,3) == '<p>' && substr($data, -4) == '</p>') { $data = substr($data, 3); $data = substr($data, 0, -4); } str_replace("<p>","</p><p>",$data); str_replace("</p><p></p><p>","</p><p>",$data); } $Case = paragraphs($_POST["txtCase"]); Quote Link to comment https://forums.phpfreaks.com/topic/110406-solved-function-not-working-need-help-please/ Share on other sites More sharing options...
kenrbnsn Posted June 16, 2008 Share Posted June 16, 2008 You need to return data to the calling script. <?php function paragraphs($data) { strip_tags($data, "<p>"); if(substr($data, 0,3) == '<p>' && substr($data, -4) == '</p>') { $data = substr($data, 3); $data = substr($data, 0, -4); } str_replace("<p>","</p><p>",$data); str_replace("</p><p></p><p>","</p><p>",$data); return($data); // added the return statement } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/110406-solved-function-not-working-need-help-please/#findComment-566412 Share on other sites More sharing options...
jesushax Posted June 16, 2008 Author Share Posted June 16, 2008 a i see silly me thanks but now im having trouble with the actuall function itself its still posting <br /><br /> values after ive took them out? function paragraphs($data) { strip_tags($data, "<p>"); if(substr($data, 0,3) == '<p>' && substr($data, -4) == '</p>') { $data = substr($data, 3); $data = substr($data, 0, -4); } str_replace("<br /><br />","</p><p>",$data); str_replace("<br />","",$data); str_replace("<p>","</p><p>",$data); str_replace("</p><p></p><p>","</p><p>",$data); return($data); } Quote Link to comment https://forums.phpfreaks.com/topic/110406-solved-function-not-working-need-help-please/#findComment-566416 Share on other sites More sharing options...
.josh Posted June 16, 2008 Share Posted June 16, 2008 can you give example(s) of what $data is supposed to hold? Quote Link to comment https://forums.phpfreaks.com/topic/110406-solved-function-not-working-need-help-please/#findComment-566431 Share on other sites More sharing options...
jesushax Posted June 16, 2008 Author Share Posted June 16, 2008 gets its value from a form $Case = paragraphs($_POST["txtCase"]); and the form just has basic text inputted in it Quote Link to comment https://forums.phpfreaks.com/topic/110406-solved-function-not-working-need-help-please/#findComment-566452 Share on other sites More sharing options...
.josh Posted June 16, 2008 Share Posted June 16, 2008 try adding $data = ... before all your str_replace(...); function paragraphs($data) { strip_tags($data, "<p>"); if(substr($data, 0,3) == '<p>' && substr($data, -4) == '</p>') { $data = substr($data, 3); $data = substr($data, 0, -4); } $data = str_replace("<br /><br />","</p><p>",$data); $data = str_replace("<br />","",$data); $data = str_replace("<p>","</p><p>",$data); $data = str_replace("</p><p></p><p>","</p><p>",$data); return($data); } Quote Link to comment https://forums.phpfreaks.com/topic/110406-solved-function-not-working-need-help-please/#findComment-566470 Share on other sites More sharing options...
jesushax Posted June 16, 2008 Author Share Posted June 16, 2008 hey works now! thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/110406-solved-function-not-working-need-help-please/#findComment-566478 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.