note 100995 deleted from function.strip-tags by aharvey

From: Date: Thu, 20 Sep 2012 12:13:59 +0000
Subject: note 100995 deleted from function.strip-tags by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190923@lists.php.net to get a copy of this message
Note Submitter: frank at silverwolf media ddoott comm ---- Note that strip_tags may stumble when it encounters two consecutive quotes. Regardless of whether that's a bug or a feature (different PHP versions seem to behave differently) here's a workaround: <?php $wtf = ' <p>First line</p> <a href=\"foo">bar</a> <p>Second line</p> <a href=\"foo\"">bar</a> <p>Third line</p> '; echo 'Raw: ' . $wtf . "\n"; echo 'strip_tags(): ' . strip_tags ($wtf); echo 'Regexp: ' . preg_replace ('/<[^>]*>/', '', $wtf); ?> Raw output: <p>First line</p> <a href=\"foo">bar</a> <p>Second line</p> <a href=\"foo\"">bar</a> <p>Third line</p> strip_tags() output: First line bar Third line preg_replace() output: First line bar Second line bar Third line

« previous php.notes (#190923) next »