Raflianrizqi Ukasah Raflianrizqi Ukasah - 3 months ago 10
PHP Question

how to remove symbol ("_") & (^) on php?

i want to remove

"_"
and
^
from output this code

foreach( $objYahooStock->getQuotes() as $code => $stock)
{
$stock[0] = preg_replace('/_.*/','',$stock[0]);
?>

Symbol : <?php echo $stock[0]; ?> <br />
Name : <?php echo $stock[1]; ?><br>
Realtime Last Price : <?php echo $stock[2]; ?><br>
Change Realtime : <?php echo $stock[3]; ?>
<hr>
<?php


i tried use
preg_replace()
but still not working to remove
"_"
and
^


This is My output

Answer

Use a str_replace on those two characters and replace with nothing.

$string = str_replace(array("_","^"), "", $string);