Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.