Кемеровские программисты php общаются здесь
-
Anonymous
Php str_replace () и preg_replace () не работает с HTML
Сообщение
Anonymous »
Когда я пытаюсь выполнить str_replace () или preg_replace () В рамках функции, содержимое не изменяется.
Содержание в Переменная $ sadrzaj < /code>: < /p>
Код: Выделить всё
$sadrzaj = '
asdasdasds
[url=http://www.example.com/wp-content/uploads/2018/11/image.jpg]
[img]http://www.example.com/wp-content/uploads/2018/11/image.jpg[/img]
[/url]
asdasdasd
asdasd
asdada
[url=http://www.example.com/wp-content/uploads/2018/11/image_02.jpg]
[img]http://www.example.com/wp-content/uploads/2018/11/image_02.jpg[/img]
[/url]
asdasd';
< /code>
Моя функция to_je_to () < /code>: < /p>
function to_je_to($content){
preg_match_all('//', $content, $images);
//print_r($images);
if(!is_null($images)){
foreach($images[1] as $index => $value){
if(strpos($images[1], 'size-full') !== false){
//if(preg_match('/alt=""/', $value)){
$new_img = preg_replace('
Подробнее здесь: [url]https://stackoverflow.com/questions/53490631/php-str-replace-and-preg-replace-not-working-with-html[/url]
1739143685
Anonymous
Когда я пытаюсь выполнить str_replace () или preg_replace () В рамках функции, содержимое не изменяется.
Содержание в Переменная $ sadrzaj < /code>: < /p>
[code]$sadrzaj = '
asdasdasds
[url=http://www.example.com/wp-content/uploads/2018/11/image.jpg]
[img]http://www.example.com/wp-content/uploads/2018/11/image.jpg[/img]
[/url]
asdasdasd
asdasd
asdada
[url=http://www.example.com/wp-content/uploads/2018/11/image_02.jpg]
[img]http://www.example.com/wp-content/uploads/2018/11/image_02.jpg[/img]
[/url]
asdasd';
< /code>
Моя функция to_je_to () < /code>: < /p>
function to_je_to($content){
preg_match_all('//', $content, $images);
//print_r($images);
if(!is_null($images)){
foreach($images[1] as $index => $value){
if(strpos($images[1], 'size-full') !== false){
//if(preg_match('/alt=""/', $value)){
$new_img = preg_replace('
Подробнее здесь: [url]https://stackoverflow.com/questions/53490631/php-str-replace-and-preg-replace-not-working-with-html[/url]