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,376 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,376
Overall visits to all the topics: 4,980,165
Daily average (Calculated from the website subscription day): 2,065.60
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Php
Current order: by category: Programming Php
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:
Php Date: Full Disaggregated Date Difference Accounting Timezones And Daylight Identification Number: 453 Visitors: 8,738 PHP Date: Disaggregated Date Difference As Interlapsed Days Hours Minutes Second Identification Number: 452 Visitors: 8,899 PHP Pass To Javascript Php Array Associative Array Or Matrix Identification Number: 419 Visitors: 10,862 PHP: Retrounpad A Matrix Array Table: Remove Shared Empty Columns Identification Number: 412 Visitors: 9,310 PHP: Strip Tags But Register Offsets. Replace Text Without Affecting Html Tags. Identification Number: 407 Visitors: 9,376 Php Check Whether A Web Site Or A Web Resource Exists/Responds Identification Number: 391 Visitors: 12,397 Php: Get Value Of Specific Html Meta Tag Identification Number: 389 Visitors: 17,844 Php Given Url Fetch Youtube Video Codes Embed/Include Video In Other Webpage Identification Number: 388 Visitors: 18,291 Php Find Length Of Texts Or Longest Within Instances Of A Given Html Tag Type Identification Number: 387 Visitors: 14,692 PHP: Match Each Array Item Once With All The Other Array Items Identification Number: 370 Visitors: 14,334
External services
This page of this subscriber uses external services: Hide