Q:

Replace all square brackets found in a string

I receive from a server some strings containing [ and ] before they reach the client side: I should convert them to ( and ). I thought I could use str_replace but I feel there should be something more "compact" (that is: if I'm not wrong, I should call str_replace on the same string four times...).
Any help is appreciated.

A:

<?php
$phrase  = "[10*[2+3]]+[5*2]+3";
$remov = array("[", "]");
$replc   = array("(", ")");
echo $newphrase = str_replace($remov, $replc, $phrase);
?>

