I want to replace all "mailto:" links in html with plain emails.
In: text .... <a href="mailto:[email protected]">not needed</a> text
Out: text .... [email protected] text
I did this:
$str = preg_replace("/\<a.+href=\"mailto:(.*)\".+\<\/a\>/", "$1", $str);
But it fails if there are multiple emails in string or html inside "a...
I have a following string and I want to extract image123.jpg.
..here_can_be_any_length "and_here_any_length/image123.jpg" and_here_also_any_length
image123 can be any length (newimage123456 etc) and with extension of jpg, jpeg, gif or png.
I assume I need to use preg_match, but I am not really sure and like to know how to code it or ...
<li class="zk_list_c2 f_l"><a title="abc" target="_blank" href="link">
abc
</a> </li>
how would i extract abc and link?
$pattern="/<li class=\"zk_list_c2 f_l\"><a title=\"(.*)\" target=\"_blank\" href=\"(.*)\">\s*(.*)\s*<\/a> <\/li>/m";
preg_match_al...
I'm trying to loop through the results from the Last.fm API but it's not working.
function get_url($url){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
...
I have this code so far which perfectly but relies on there being a directory in place:
$path = '/home/sites/therealbeercompany.co.uk/public_html/public/themes/trbc/images/backgrounds/'.$this->slug;
$bgimagearray = array();
$iterator = new DirectoryIterator($path);
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile() && !p...
Warning (2): Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/iframeworking/iframe/app/models/frame.php:7) [COREcake/libs/controller/controller.php, line 647]
here is the code from frame.php:
<?php
class Frame extends AppModel
{
var $name = 'Frame';
var $belongsTo = array('Use...
When I have to render textarea content to the front end I usually pass it thru a function that converts newlines to <br/> tags and double newlines signal paragraph tags so blocks of text get surrounded by <p> and </p> tags.
To save time I usually use a ready made PHP function from the wordpress codebase. You can get the link from the ma...
What is the best php encoder software?
=========================================
http://www.freedownloadmanager.org/downloads/php_encoder_software/
http://forums.digitalpoint.com/showthread.php?t=596680
or another.
Everybody say Zend Guard. But you can decode/decript zend's files at the page http://www.showmycode.com/
I think, Sour...
I have the following query:
$select = mysql_query("SELECT * FROM posts WHERE id = $postIds");
while ($return = mysql_fetch_assoc($select)) {
$postUrl = $return['url'];
$postTitle = $return['title'];
echo "<h1><a href='$postUrl'>".$postTitle."</a></h1>";
}
Now the problem is, the variable...
I'm using PHP to scrape a website and collect some data. It's all done without using regex. I'm using php's explode() method to find particular HTML tags instead.
It is possible that if the structure of the website changes (CSS, HTML), then wrong data may be collected by the scraper. So the question is - how do I know if the HTML struct...
hi all
I have a php file that contains a form (witch contains 2 input boxes and a submit button) for updating a contact. I managed to fill the fields with the contact's data, but I can't detect if the submit button is clicked
form looks like this
echo "<form action=Contact.php><table>".
"<tr><td>First Name</td><td><input type=text siz...
A few months ago, I was working on a PHP project in Aptana Studio. It was version 1.5 or something. Later I installed Aptana 2.0 and created a new project with the same files. Back then it was UTF-8 so I chose UTF-8 for the project's text file encoding.
When I make changes in any PHP file using Aptana, it gives the error:
Warning: Ca...
Could you write this 'cleaner' ? Just a simple question from a beginner:)
if(isset($_GET['tid']) && trim($_GET['tid'])!==""){
$act = 'tid';
$tid = trim($_GET['tid']);
}elseif(isset($_GET['fid']) && trim($_GET['fid'])!==""){
$act = 'fid';
$fid = trim($_GET['fid']);
}elseif(isset($_GET['mid']) && trim($_GET['mid'])!==""){
$act = 'mid';
...
I have two virtual hosts on windows(for example: test1.dev and test2.dev). But it always load content of test1.dev for both virtual hosts.
Following are my files:
hosts:
127.0.0.1 localhost
127.0.0.1 test1.dev
127.0.0.1 test2.dev
httpd.conf:
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
...
As you know, the @ characters before a php istruction suppress every eventual warning, error or notice from being raised.
Personally, i dont like this tecnique, becose i prefer to handle those errors, and in a real life, the error must no happen or have to be managed.
By the way, i find this tecnique to be applied in many scripts (cms ...
I'm running my own (albeit, basic) benchmarks in a linux-based sandbox. However, I'd love to find a per-function or per-task performance / benchmark reference or utility for comparison.
Does this exist?
Of course I've done my own fair diligence / searching and have so far come up empty handed..
(I'm primarily interested in information...
Using the XMLReader XML parser in PHP 5.3, I need to get the line number of the current node. A column number or total offset from the beginning of the file would be nice, too.
Hopefully I don't have to use some hack like parsing every raw node string for newlines (with readOuterXML()), but I don't see a getLineNo() property like in th...
Greetings cake experts, I have a question that I think would really help a lot of people getting started with cakePHP. I have a feeling it will be easy for some of you, but it is quite challenging to me.
I have a simple database with multiple tables. I can't figure out how to make cakePHP display the values associated with a foreign key...
Hi All
I don't usually use regular expressions, hence my question. I need a regex to match the following:
'{any-string}'.
Any assistance appreciated.
...
How do I extract foo from the following URL and store it in a varialbe, using regex in php?
http://example.com/pages/foo/inside.php
I googled quite a bit for an answer but most regex examples were too complex for me to understand.
...