note 104827 added to function.substr-count

From: Date: Sat, 09 Jul 2011 18:33:40 +0000
Subject: note 104827 added to function.substr-count
Groups: php.notes 
Request: Send a blank email to php-notes+get-181384@lists.php.net to get a copy of this message
Here is the function that counts the number of TAG occurrences: function tag_count($tag, $text, $close = false, $ignore_case = false) { return preg_match_all('/<'.($close ? '\/' : '').$tag.'([^>]*?)>/'.($ignore_case ? 'i' : ''), $text, $v); } Examples: // count of the <b...> tags print tag_count('b', 'Hello <b style="font-size:14pt">World</b> <b>Test', false); > returns 2 // count of the </b...> tags print tag_count('b', 'Hello <b style="font-size:14pt">World</b> <b>Test', true); > returns 1 ---- Server IP: 77.88.252.46 Probable Submitter: 91.200.180.180 ---- Manual Page -- http://www.php.net/manual/en/function.substr-count.php Edit -- https://master.php.net/note/edit/104827 Del: integrated -- https://master.php.net/note/delete/104827/integrated Del: useless -- https://master.php.net/note/delete/104827/useless Del: bad code -- https://master.php.net/note/delete/104827/bad+code Del: spam -- https://master.php.net/note/delete/104827/spam Del: non-english -- https://master.php.net/note/delete/104827/non-english Del: in docs -- https://master.php.net/note/delete/104827/in+docs Del: other reasons-- https://master.php.net/note/delete/104827 Reject -- https://master.php.net/note/reject/104827 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181384) next »