Jump to content


Photo
- - - - -

Finding a space outside of a HTML tags


  • Please log in to reply
No replies to this topic

#1 Allstar

Allstar

    Forum Newcomer

  • Members
  • Pip
  • 51 posts
  • Gender:Not Telling
  • Location:Thunderbird 5
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 30 March 2012 - 03:27 PM

I'm trying to find a 'space' outside of a html tag

$counter = 0;
$insert_at = 160; // start at 160 chars into content
do {
	$look_from = $insert_at = @strpos($content, ' ', $insert_at);	

	$before_opening_tag = strrpos($content, '<', $look_from);
	$before_closing_tag = strrpos($content, '>', $look_from);
	
	$after_opening_tag = strpos($content, '<', $look_from);
	$after_closing_tag = strpos($content, '>', $look_from);

	$counter++;
	if ( $counter == 5) { break; }
} while (
	($before_opening_tag > $before_closing_tag)
	&&
	($after_closing_tag < $after_opening_tag)
);

The while conditional should read like
"is the first closing tag less chars from beginning than an open tag?" (looks like: '<>SPACE')
AND
"is the first opening tag more chars after the next closing tag?" (looks like: 'SPACE<>')

overall I want this: "<img width="100" />SPACE<a href="">"
and not this: "<img width="100" /><aSPACEhref="">" or "<img width="100"SPACE/> <a href="">"

Edited by Allstar, 30 March 2012 - 03:30 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users