Example: <div style="font-size:15px;">first matched here</div>
我想让PHP能够找到这一具体信息。
i 曾尝试过许多事前工作,但并不理解区域评价。
HELP?
Example: <div style="font-size:15px;">first matched here</div>
我想让PHP能够找到这一具体信息。
i 曾尝试过许多事前工作,但并不理解区域评价。
HELP?
<?php
$data = aaa <div class="main">content</div> bbb ;
preg_match_all ("/<div.*?>([^`]*?)</div>/", $data, $matches);
//testing the array $matches
//$matches is an array contains all the matched div elements and its contents
//print_r($matches);
?>
Try this for matching all the div elements
努力:
<?php
//the string to search in
$s = "<div style="font-size:15px;">first matched here</div>";
//set up an empty array to facilitate the results
$matches = array();
//match with regex
//pattern has to start and end with the same character (of your choice)
//here it s #
//start criteria is an opening div <div> that may contain some text
//between v and >, so use .*?
//the dot means "any character", the *? means "any number, but as few as possible"
//then, define the part to capture. this is done with paranthesis
//define what to capture. this would be any character, and as few as possible
//and finally end criteria </div>
//matches are stored in the out parameter $matches
preg_match("#<div.*?>(.*?)</div>#", $s, $matches);
echo "<pre>";
print_r($matches);
echo "</pre>";
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...