0

I know the title sounds like an easy thing to do. But its not. I want to check that my user's message has 2 -'s in it. Then replace the first - with <s> then the second one with </s> and i dont know how to check for to dashe's but this is what i have to change it

<?php
$ID = $_COOKIE['idCookie'];
$memberid = $_GET['id'];
$query = mysql_query("SELECT * FROM `private_messages` WHERE to_id='$ID' AND To_Deleted='0' AND from_id='$memberid' OR to_id='$memberid' AND from_id='$ID'");
while($row = mysql_fetch_assoc($query)){
    $subject = $row['subject'];
    $toid = $row['to_id'];
    $read = $row['opened'];
    $fromid = $row['from_id'];
    $message = $row['message'];
    $message = str_replace($smile_symble, $smile_pic, $message);
    $strike = array("-","-"); //probably dont need 2 do i?
    $strike1 = array("<s>","</s>");
    $message = str_replace($strike, $strike1, $message)
?>
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by jeremym001
0
<?php

$sample_text = 'Things between hyphens will be -striked out-';

$new_text = preg_replace('/\-(.*)\-/', '<s>$1</s>', $sample_text);

echo $new_text;

?>

Edited by jeremym001

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.