<?php $string = "[a,b] some text [b,a] and some more"; $c = 1; echo preg_replace('/\[([^,]+),([^]]+)\]/', $c ? '$1' : '$2', $string) . "\n"; $c = 0; echo preg_replace('/\[([^,]+),([^]]+)\]/', $c ? '$1' : '$2', $string) . "\n";
You have javascript disabled. You will not be able to edit any code.