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)
?>
Member Avatar for jeremym001
<?php

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

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

echo $new_text;

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.