I'm writing a simple templating layer in PHP but I've got myself a little stuck. Here's how it works at the moment:
Firstly I use fetch_template to load the template contents from the database - this works (and I collect all the templates at startup if you're interested).
I use PHP variables in my template code and in the logic - e.g.:...
Hello,
I would like such empty span tags (filled with and space) to be removed:
<span> </span>
I've tried with this regex, but it needs adjusting:
(<span>( |\s)*</span>)
preg_replace('#<span>( |\s)*</span>#si','<\\1>',$encoded);
Cheers.
...
Hi,
I need to store of 100-200 data in mysql, the data which would be separated by pipes..
any idea how to store it on mysql? should I use a single column or should I make many multiple columns? I don't know exactly how many data users will input.
I made a form, it halted at the part where multiple data needs to be stored.
Anyone kn...
Are there any robust and mature HTML parsers available for PHP? A quick skimming of PEAR didn't turn anything up (lots of classes for generating HTML, not so much for consuming), and Google taught me a lot of people have started and then abandoned a variety of parser projects.
Not interested in XML parsers (unless then can consume non-...
which one of the two is more spread? I want to read out the version number from http://freshmeat.net/projects-xml/mysql/mysql.xml?branch_id=46519 but I want to use the one which more people have.
If you know another way to get the latest stable version number from mysql please tell me ;)
...
On a site where 90% of the pages use the same libraries, should you just load the libraries all the time or only load them when needed? The other pages would be ajax or simple pages that don't have any real functionality.
Also, should you only load the code when needed? If part way down a page you need a library, should you load it then...
PHP provides a mechanism to register a shutdown function:
register_shutdown_function('shutdown_func');
The problem is that in the recent versions of PHP, this function is still executed DURING the request.
I have a platform (in Zend Framework if that matters) where any piece of code throughout the request can register an entry to b...
Is there a PHP version of JavaScript's confirm() function?
If not, what are my other options or how do I make something similar to the confirm()?
...
Greetings,
I have the following code
<?
include("conn.php");
$sn=$_GET["sn"];
$sql="select * from kpi where no='$sn'";
$result=mysql_query($sql,$connection) or die(mysql_error());
while($row=mysql_fetch_array($result)) {
$sn=$row['id'];
$no=$row['no'];
...
I'm building a small web app in PHP that stores some information in a plain text file. However, this text file is used/modified by all users of my app at some given point in time and possible at the same time.
So the questions is. What would be the best way to make sure that only one user can make changes to the file at any given point ...
I have been writting a keyword search script based on this tutorial:
http://www.hackosis.com/2007/11/06/howto-simple-search-engine-with-php-and-mysql/
Like some of the commenters mentioned, the script only ends up returning results based on the last word in the search terms. So I have also tried to implement one of the suggestions from ...
Greetings,
I have data stored on mysql with delimiter "," in 1 table.
I have rows and column stored on database too.
Now i have to output the data using rows and column number stored on database to draw the table.
Rows and column number are user input, so it may varies.
Let say, there is number 3 on column and 3 on rows.
I need to ...
Python provides the "*" operator for unpacking a list of tuples and giving them to a function as arguments, like so:
args = [3, 6]
range(*args) # call with arguments unpacked from a list
This is equivalent to:
range(3, 6)
Does anyone know if there is a way to achieve this in PHP? Some googling for variations of "PHP Unpa...
Does anyone know of a good YAML Parser for PHP? If so, what are the pros and cons of this library?
Update: Starting a bounty to get fresh input. What's the status of YAML parsers in 2010? Any new developments?
...
Which php sites would you recommend following for php news, new open source projects, some that have been around for a while, etc.
Just looking to stay on top of the php industry and also find new tricks and what not to make my programming life easier :)
G-Man
...
I'm writing a script that pulls XML data from wowarmory.com, using PHP 5 and cURL:
$url = "http://www.wowarmory.com";
$userAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$url);
$str ...
I'm currently considering the use of Reflection classes (ReflectionClass and ReflectionMethod mainly) in my own MVC web framework, because I need to automatically instanciate controller classes and invoke their methods without any required configuration ("convention over configuration" approach).
I'm concerned about performance, even th...
Please excuse my lack of knowledge... I know there is a lot of documentation on the internet related to this but I still don't understand.
My situation is this:
I have an XML file that I need import and eventually replace daily with.
<item>
<model>AA311-Pink</model>
<title>1122</title>
<price>19.43</price>
<category>cat</cate...
How do you convert a number to a string showing dollars and cents?
eg:
123.45 => '$123.45'
123.456 => '$123.46'
123 => '$123.00'
.13 => '$0.13'
.1 => '$0.10'
0 => '$0.00'
...
What are some of the ways you have implemented models in the Zend Framework?
I have seen the basic class User extends Zend_Db_Table_Abstract and then putting calls to that in your controllers:
$foo = new User;
$foo->fetchAll()
but what about more sophisticated uses? The Quickstart section of the documentation offers such an example ...