Reading it again still puzzles me.
Let’s start by implementing tags that create boldface and italic text. Let’s say we want to begin bold text and [EB] to end bold text. Obviously, we must replace with <strong> and [EB] with </strong>.2 Achieving this is a simple application of eregi_replace:3
$joketext = eregi_replace('\', '<strong>', $joketext);
$joketext = eregi_replace('\[eb]', '</strong>', $joketext);
Notice that, because [ normally indicates the start of a set of acceptable characters in a regular expression, we put a backslash before it in order to remove its special meaning. As backslashes are also used to escape special characters in PHP strings, we must use a double backslash for each single backslash that we wish to have in the regular expression. Without a matching [, the ] loses its special meaning, so it doesn’t need to be escaped, although you could put a (double) backslash in front of it as well if you wanted to be thorough.
I get it that the [ must be escaped by a backslash, but why would double backslashes be necessary here? This should work the same:
$joketext = eregi_replace('[b]', '<strong>', $joketext);
The single backslash sees to it that is taken literally and not as a regex code only allowing 'b'. What am I missing?