在php中替换两个char(特殊符号)之间的字符串

I have a string like: He *is* a good boy. How *are* you. Then I want to replace is and are with input type textbox means replace things between asterisk(*). How can I get this Please help me out.

<?php
    $buffer = 'He *is* a good boy. How *are* you.';
    echo "Before: $buffer<br />";
    $buffer = preg_replace_callback('/(\*(.*?)\*)/s', 'compute_replacement', $buffer);
    echo "After: $buffer<br />";

    function compute_replacement($groups) {
        // $groups[1]: *item*
        // $groups[2]: item
        return '<input type="text" value="'.$groups[2].'" />';
    }
?>

The result:

enter image description here

try this,

<?php
$x="hai, *was/is* are you, is this *was* test ";
echo preg_replace("/\*[\w\/]*\*/","",$x);
?>

Use preg_replace(); e.g:

<?php

$pattern = '/\*\w+\*/';
$string  = 'he *is* a good boy';
$replacement = 'was';

echo preg_replace($pattern, $replacement, $string);

Yields:

he was a good boy

Try in this way:

$txt = "He *is* a good boy. How *are* you.";
$_GET['one'] = "doesn't";
$_GET['two'] = "think about";

preg_match_all( '{\*[^*]+\*}',$txt,$matches );
$txt = str_replace( $matches[0][0], $_GET['one'], $txt );
$txt = str_replace( $matches[0][1], $_GET['two'], $txt );

echo $txt;

eval.in demo

or, with preg_replace, in this way:

$txt = preg_replace
(
    '/^(.*)\*[^*]+\*(.*)\*[^*]+\*(.*)$/',                  # <-- (Edited)
    "\\1{$_GET[one]}\\2{$_GET[two]}\\3", 
    $txt 
);