$test_text2 = eregi_replace("[a=(.)*]", "<a href=\1>", $test_text);
That piece .* searches as many letter as possible, so in your case it replaces the whole string. i.e.
your string:
"[a=\"/it/?main_url=/it/helpdesk/smilies.html\"] here [/a] "
becomes understood like this(already in the first replacement):
"[a=.*] "
So, I'd use preg_replace, because there you can use the ?-sign to mean that you want as few letters as possible... This may seem a bit complicated, but it does the BOTH replacements you wanted at the same time:
$test_text = "[a=\"/it/?main_url=/it/helpdesk/smilies.html\"] here [/a] ";
$test_text2 = preg_replace("/(\\[a=)(.*?)\\](.*?)(\\[\\/a\\])/i","<a href=$2>$3</a>",$test_text);
also even if you'd do it using eregi, you'd have to use '\'-character to escape '[' and ']', because those are used for special purposes(defining for example a range of numbers i.e. [0-4] ). The syntax of preg is quite useful to learn if you're going to hang around with php for longer time. 🙂 Have fun.