I'm learning Regex now, and'm quite stumped. I'd ask the instructor, but he's said to be no good with them either yesterday. I've made a test-page to get the hang of it, but its output's not what it should do, according to how I read the code.
Code:
*$string = "Best niet [b] bevet Moddervet Niet vet";
*echo $string, "<br>";
*eregi("(\[b\])", $string, $resultaat);
*$open_tags = count($resultaat);
*eregi("(\[/b\])", $string, $resultaat_closed);
*$closed_tags = count($resultaat_closed);
*echo "Open: ", $open_tags, "<br>Closed: ", $closed_tags;
That's my code (stripped of all set-up tags like <html> etc). This's its output:
Code:
Best niet [b] bevet Moddervet Niet vet
Open: 2
Closed: 0
No matter how many results it should find, it'll always give 2, except if there're no results, like in Closed. Then it'll give 0. I don't see why it doesn't give 1 for the Open one in the current example. Any help'd be greatly appreciated