Home Backend Development PHP Tutorial 替换字符串的有关问题

替换字符串的有关问题

Jun 13, 2016 am 10:14 AM
height quot width

替换字符串的问题
不用js,想将替换字符串width="80" height="80",如何写呢?
传入字符串

HTML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><img  src="/static/imghw/default1.png" data-src="http://www.macaucentral.com/dev/images/stories/jreviews/649_Image00001_1304589016.jpg" class="lazy"    style="max-width:90%" alt="替换字符串的有关问题" >
Copy after login

传出字符串
HTML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><img  src="/static/imghw/default1.png" data-src="http://www.macaucentral.com/dev/images/stories/jreviews/649_Image00001_1304589016.jpg" class="lazy"    style="max-width:90%"  style="max-width:90%" alt="替换字符串的有关问题" >
Copy after login



------解决方案--------------------
echo str_replace('width="200"','width="80" height="80"',$str);
------解决方案--------------------
PHP code
<?php $str='<img  src="/static/imghw/default1.png"  data-src="http://www.macaucentral.com/dev/images/stories/jreviews/649_Image00001_1304589016.jpg"  class="lazy"     style="max-width:90%" alt="替换字符串的有关问题" >';echo preg_replace('/width="\d+"/','width="80"  style="max-width:90%",$str);<br><font color="#e78608">------解决方案--------------------</font><br>如果要在前台展示的时候动态替换的话那就非js莫属了。<br>要是后台那就php处理吧<div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does the width of html mean? What does the width of html mean? Jun 03, 2021 pm 02:15 PM

In HTML5, width means width. The width attribute defines the width of the element's content area. You can add inner margins, borders, and outer margins outside the content area. You only need to set "element {width: value}" to the element.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Detailed explanation of CSS dimension properties: height and width Detailed explanation of CSS dimension properties: height and width Oct 21, 2023 pm 12:42 PM

Detailed explanation of CSS dimension properties: height and width In front-end development, CSS is a powerful style definition language. Among them, height and width are the two most basic dimension attributes, used to define the height and width of the element. This article will analyze these two properties in detail and provide specific code examples. 1. Height attribute The height attribute is used to define the height of an element. You can use pixel, percentage or

What are the methods for expressing width value in css? What are the methods for expressing width value in css? Nov 13, 2023 pm 05:47 PM

Methods include pixel value, percentage, em unit, rem unit, vw/vh unit, auto, fit-content, min-content, max-content. Detailed introduction: 1. Pixel value (px): The pixel value is fixed, and its width remains unchanged no matter how the screen resolution changes. For example: width: 300px; 2. Percent (%): The percentage width is relative to the width of the parent element. For example: width: 50%; 3, em unit, etc.

What does width mean in iframe What does width mean in iframe Sep 19, 2023 pm 12:00 PM

Width in iframe means the width of the specified frame, which can control the width of the iframe displayed on the page. Acceptable values ​​for width: 1. Fixed pixel value, width="300px", the frame width will always remain unchanged, no matter how the size of the browser window changes; 2. Percentage value, width="50%", the width of the frame It will be adaptively adjusted according to the width of its parent element; 3. Automatic value, width="auto", the width of the frame will be adaptively adjusted according to the width of its content.

jQuery quickly removes the height attribute of an element jQuery quickly removes the height attribute of an element Feb 27, 2024 pm 02:09 PM

jQuery is a JavaScript library widely used in web development. It provides developers with many convenient methods to manipulate and process web page elements. In actual development, we often need to operate the attributes of web page elements. One of the common requirements is to remove the height attribute of the element. In this article, we will introduce how to use jQuery to quickly remove the height attribute of an element and provide specific code examples. To remove the height attribute of an element, you can use jQu

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 Jun 13, 2016 am 10:15 AM

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。

图片消失怎么解决 图片消失怎么解决 Apr 07, 2024 pm 03:02 PM

图片消失如何解决先是图片文件上传$file=$_FILES['userfile'];  if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'

See all articles