The Identification Number and Password fields need to be filled in. Moreover, you cannot send messages devoid of contents Adding further data is not allowed because this topic has been closed Print You provided no password: you have to write it in the textfield beside the command delete for the topic you want to delete Are you sure you want to delete this comment? You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed Provide the project number Insufficient form parameters: you forgot to fill in some field/s
 
member picmember pic
 
Snippets of A
 
info Below you can find the text of the snippet you want to read, and the list of the other snippets by this author if available.
What are snippets?
Share on MySpace

PHP: Strip Tags But Register Offsets. Replace Text Without Affecting Html Tags.

Snippet: Identification Number »   Snippet: Inclusion syntax »
Visitors: 9,332 Tagged by its author as: Programming Php Characters (in origin): 3,627 (pages: ~ 1)
Author: Em@il Permalink Cast your vote for this topic Printable version
OBJECTIVE: the purpose of this function is not that of stripping tags (as strip_tags does) but of returning the offset positions where the text wrapped within tags is located.  
Such data is useful for the following process at least: manipulating (for instance: searching and replacing) an input text without affecting its html tags (assumed as present in such input text - though the function would return the expected outcome also if tags are absent).  
 
That is, manipulating text only within the portions that do not represent html tags, and then rebuild the original text inclusive of the html tags (which therefore are not stripped, thence the difference with strip_tags) retaining the manipulations.  
function stripTagsOffsets($input=''){
$opentags=substr_count($input, '<'); $closedtags=substr_count($input, '>');
if(!$opentags || !$closedtags){return array(array(strlen($input), 0));};
$array=array(); $afterLastClosedTagPosition=-1; $beforeNextOpenTagPosition=strpos($input, '<');
	for($i=0; $i<$opentags; $i++){
	$array[]=array($beforeNextOpenTagPosition, ++$afterLastClosedTagPosition);
	$beforeNextOpenTagPosition=strpos($input, '<', ++$beforeNextOpenTagPosition);
	$afterLastClosedTagPosition=strpos($input, '>', ++$afterLastClosedTagPosition);
	}
array_push($array, array( strlen($input), ++$afterLastClosedTagPosition ));
return $array;/*keep this comment to reuse freely
http://www.fullposter.com/?1*/}
Remove colors  
INPUTS: a string.  
 
RETURNS: array of arrays. Each nested array is composed of two entries, both numbers:  
the first entry is the index position of the char soon before the next html tag bracket is to open (<);  
the second entry is the index position of the first char soon after the preceding html tag was closed (>)  
 
Example of use:  
function usageExample($input=''){/*INCLUDE FUNCTION: stripTagsOffsets.
This is a MERE example function, assuming the passed argument is in the shape returned by stripTagsOffsets*/
$outcome=stripTagsOffsets($input); print_r($outcome); print '<hr>';
$L=sizeof($outcome); $output=array(); $n=0;
for(; $n<$L; $n++){
$output[]='<xmp>'.
		/*Offsets to use to grab tag BEFORE:*/substr($input, $outcome[$n-1][0], $outcome[$n][1]-$outcome[$n-1][0]).
	"</xmp>\n ".
			/*Offsets to use to grab text, plus: ACTION instance: replacing 'e' in TEXT only NOT in tags:*/str_replace('e', 'EEE', substr($input, $outcome[$n][1], $outcome[$n][0]-$outcome[$n][1])).
	"\n<xmp>".
		/*Offsets to use to grab tag AFTER:*/substr($input, $outcome[$n][0], $outcome[$n+1][1]-$outcome[$n][0])
	."</xmp><hr />";
}print implode('', $output);}

$meaninglessText='This string begins with an <em>em tagged text</em> and <span><span></span></span>foo foo <strong>blod with <em>nested em</em></strong> and anchor to say: go <a href="http://www.dunno.com">click here to visit dunno.com</a> etc etc an image here <div style="text-align:center"><img src="fooem.gif" alt="" /> a photo caption</div> plus a break line <br /> and more text with this <strong><em>bold and em once</em></strong> and empty tag <strong></strong> and empty nested tags <strong><em></em></strong> true end here.';

usageExample($meaninglessText);
Remove colors
Printable version To exclude hyperlinks from the print, check the checkbox »
Rss

Cast your vote for this topic

To perform this operation it is not necessary to be Full Poster members.
«Negative Positive»
Click here to save your vote (Current average: 0.00, Voters: 0)
Are you the author of this topic and do you want to append quickly more text? click here
Other topics
This subscriber has a blog too: Read the blog: 57 Shoutbox: 103 reviews: 153
Visitors: 9,332
Overall visits to all the topics: 4,958,707
Daily average (Calculated from the website subscription day): 2,059.26
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Php
Current order: normal
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(4), Books(236), Critical Reviews and Essays(4), Dictionaries(1), Emergency Care(4), Epistles Letters and Advice(5), Fantasy Epics and Fables(1), History and Documents(5), Humor and Jokes(2), Methematics(2), Music and Lyrics(6), News Digests and Press Reviews(1), Novels Poetry and Stories(3), Philosophy Reviews(7), Poetry(1), Programming(4), Programming Ajax(2), Programming Javascript(82), Programming Php(52), Psychology(1), Quotes(1), Religion Esoterica and Spirituality(12), Scientifical Reviews(4), Self Improvement(1), Sport Activities and Apparels(2), Tarots(1)
Showing topics: 1, 10
Available total: 448
View only a list of the snippets by this author: click here.
Other topics available for this author: click on any title below to view the complete item:
Fighting Competently: Anticipation, And Remember It's In His Eyes Identification Number: 465 Visitors: 312 La Musa Segreta: Superiorità Onnipervasiva Della Boxe Identification Number: 464 Visitors: 1,187 Ha Senso Il Doping Sportivo? Effetto Matteo Nello Sport E Business Sportivo Identification Number: 463 Visitors: 1,420 The Musicians Within The Music Box And Other Hereafter Stories Identification Number: 462 Visitors: 2,677 Freud And Jung In A Nutshell: Three Or So Shots At Psychoanalysis For Dummies Identification Number: 461 Visitors: 4,134 Division The Math Of Gods: Ambiguities Of Antanairesis And New Math Operations Identification Number: 460 Visitors: 4,383 The Meaning Of Cruelty Identification Number: 459 Visitors: 4,783 Dÿanèra Ad Eleusi: La Folgorazione Ontologica: Il Pensare Sistematico E Non Identification Number: 458 Visitors: 5,589 Creative Writing: How To Write A Novel. Best Tips From The Bester Professionals Identification Number: 457 Visitors: 7,392 Newsreel Pseudo Intel: The Middle East Approaching The New 20s Identification Number: 456 Visitors: 7,367
External services
This page of this subscriber uses external services: Hide