开发者

strpost can't find > character

开发者 https://www.devze.com 2023-03-25 13:59 出处:网络
I need to find an image tag in a text entered in TinyMCE. I\'m triyng to find the position of \'img\', and then, the first \'>\' starting on the position where appears \'img\'.

I need to find an image tag in a text entered in TinyMCE. I'm triyng to find the position of 'img', and then, the first '>' starting on the position where appears 'img'. So, I'm doing:

strpos($text, '>')

but this don't return anything. What I'm doin wrong? thanks!!


Thanks for the answers!!! I've found my problem:

$text = $act->getText(开发者_开发知识库ESC_RAW)

Without ESC_RAW, symbols like < and > are omitted.


have you checked your input? eventually TinyMCE has already converted it into html entities and your '>' became a '&gt;' ...?


and one more thing. if you use strpos result in if statement, like

if (strpos($text, '>')) {do_something();}

and > symbol is first in $text variable, strpos wil return 0 that is the same with false in php. you need use somthing like

if (strpos($text, '>') !== false) {do_something();}


Works fine for me

<?php 
$text = "<testing>"; 
echo strpos($text, '>') 

result: 8

Warning: &gt; isn't > !

0

精彩评论

暂无评论...
验证码 换一张
取 消