Jump to content

[SOLVED] function not working, need help please


jesushax

Recommended Posts

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"]);

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

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);
}

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);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.