In PHP, you have preg_replace($patterns, $replacements, $string), where you can make all your substitutions at once by passing in an array of patterns and replacements.
What is the equivalent in Python?
I noticed that the string and re functions replace() and sub() don't take dictionaries...
Edited to clarify based on a comment by ric...
Hi there,
I'm having a hard time quoting SQL string properly, I want to know if there's a program or a website that can help me quote the string correctly. Where I can enter the SQL strings then the website will analyze and quote it for me. Or maybe a program.. I need it cause I'm having a trouble with them..
Sorry for not providing a ...
Firefox and IE 7 are installed. I use MS Virtual PC for testing website in IE6 it works oon live site but I use XAMPP to render PHP files but h.ttp://localhost is not working Virtually running XP with IE6.
...
Hi,
I would like a PHP script to read the contents from a CSV file in the following format
id, sku
1,104101
2,105213
there are a total of 1486 entries, I believe that it's better to use a for loop instead of while !EOF.
After that, I would like to perform SQL query on a database named m118, table catalog_product_entity.
The query w...
I've discovered there is a helper to help parse RSS, but is there one to help create one?
I'd imagine there should be...
Thanks
...
OK, so I see that there are a few articles for transitioning from PHP to Java, but I am going the other way around.
I have experience with developing with C# and Java applications (these languages have roughly similar architectures).
I have recently begun to work with PHP, and there are a few things which seem very unusual from the JA...
I want a quick easy way to copy an array but the ability to specify which keys in the array I want to copy.
I can easily write a function for this, but I'm wondering if there's a PHP function that does this already. Something like the 'array_from_keys' function below.
$sizes = array('small' => '10px', 'medium' => '12px', 'large' => '13...
I think that a function called phpinfo is a function displaying environment of PHP, but results of phpinfo which I carried out from a command-line as a result of phpinfo that I displayed it on a Web server are different.
Why will these be different?
I want to become the same result.
...
$output = "<loginsuccess>";
while( $Row = mysql_fetch_object( $result ) )
{
$output .="<keyword>".$_POST['keyword']."</keyword><name>".$row['url']."</name><occur>".$row['occurrences']."</occur><queryTime>".(substr($end_time-$start_time,0,5))."</queryTime>";
}
$output .= "</loginsuccess>";
This is my PHP output, how can i convert th...
Hi guys, I want to know what's the meaning of tilde operator in regular expressions.
I have this statement:
if (!preg_match('~^\d{10}$~', $_POST['isbn'])) {
$warnings[] = 'ISBN should be 10 digits';
}
I found this document explaining what tilde means: ~
It said that =~ is a perl operator that means run this variable against this...
I am developing a CMS based on Zend Framework which have many modules, for example News and Gallery.
Each module has some part with same function as manage categories and comments (Categories and comments for News, Photos, Albums - cames from News and Gallery modules - are separate).
Can somebody give me the advise to avoid making duplic...
Hi,
I'm looking for a PHP script that can accept an XML file via a POST, then send a response....
Does anyone have any code that could do this?
So far the only code I have is this but not sure about the response or if indeed I am even going in the right direction as XML characters are not saved correctly. Any ideas?
<?php
if ( $_SER...
I'm almost sure the answer to this is "None at all!" but I'll ask anyway. If you have a conditional statement in PHP which echos a line of html, is there any difference performance-wise between these 2 examples:
<?php if ($output) { ?>
<h2><?=$output;?></h2>
<?php } ?>
and
<?php if ($output) { echo "<h2>".$output."</h2>"; } ?>
...
$keyword = $_POST['keyword'];
$start_time = getmicrotime();
$result = mysql_query(" SELECT p.page_url AS url,
COUNT(*) AS occurrences
FROM page p, word w, occurrence o
WHERE p.page_id = o.page_id AND
w.word_id = o.wor...
I am writing an Typo3 Extension and everything is working fine right now. I Access the GET Variables via
t3lib_div::_GET('rid');
This does work on the testsite I added my Extension to, but if I add it on another subsite of the same page which is in an access-restricted area this does not work. I use var_dump to look at the GET vars, ...
My site has a php page that prints out XML, for some reason though it's being truncated to 8KB in size, I've never encountered this before and all the other pages on the site remain un-truncated.
Where should I start looking for the problem and what could cause it to stop like this?
The site uses the Zend framework and the page in ques...
I'm trying to pass a username and password variable to the twitter credentials but it keeps returning that I'm not authenticated. However, when I use the actual username and password, instead of the variables, it successfully authorizes.
$username = $_POST["username"];
$password = $_POST["password"];
$url = "http://search.twitter.com/s...
On a site that I'm working on, I'm displaying results from a database query. Each page shows 15 results, so if there are 45 results returned from the query, they will be displayed on 3 separate pages, each containing 15 results.
I want the user to be able to select any number of items from the first page, then switch to the other pages ...
I asked a similar question yesterday which may have been poorly worded, either way I didn't understand and this is something I really need to crack :) I've never done it before and would be very useful for so many of my projects.
This is for a directory website. I have three tables: entry, location, and entry-locations. entry contains i...
I am trying to figure out why I'm getting this error
"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/idgcca/public_html/web-design-samples-testing.php on line 64"
echo '
<div style="float:left; width: 180px; margin: 20px 0px 10px 0px;"><a rel="lightbox[web]" title="'. $post->title .'" onmousedown="thi...