php

Zend_Date language translation

Hello ! I have a function that returns me a date string using Zend_Date. $date = new Zend_Date(); $date->setOptions(array('format_type' => 'php')); $date->setTimestamp($timestamp); return $date->toString($format); When I set $format to 'l, d F Y' I expect something like: Środa, 13 stycznia 2010 (correct polish string what means W...

sed doesn't work with PHP exec function

echo "sed -i 's/NULL/\\N/g' ".$_REQUEST['para'].".sql"; The above statement works. But it fail when I use it in exec like this... exec("sed -i 's/NULL//\/\/\N/g' ".$_REQUEST['para'].".sql"); ...

PHP array_merge_recursive with numeric keys

So I'm suppose to build a multidimensional array dynamically from a text file, and everything works perfectly except that the numeric keys are screwing me over... The text file looks something like this: a=1 b.c=2 b.d.0.e=3 b.d.0.f=4 b.d.1.e=5 b.d.1.f=6 As the array_merge_recursive doesn't work with numeric keys, the output is like...

How to implement google-maps-like zoom-and-pan system in web?

Hello, I'm writing a ticket-shop-system atm for reserving tickets for various concerts. What I have is a php-backend and a webpage that shows a .swf with some actionsscript-3 code in it, to draw in flash some sort of map and make available seats clickable for the end-user. The problem with this solution is, that there are quite large hal...

preg_match for sentences begining with 'for the'....

Pretty simple but I cant get the exact syntax working. I just want a true or false check to see if a string beings with 'for the' (case insensitive). Thanks everyone. ...

PHP DOMDocument->loadXML with XML containing ampersand/less/greater ???

I'm trying to parse an XML string containing characters & < and > in the TEXTDATA. Normally, those characters should be htmlencoded, but in my case they aren't so I get the following messages: Warning: DOMDocument::loadXML() [function.loadXML]: error parsing attribute name in Entity ... Warning: DOMDocument::loadXML() [function.loadXML]...

PHP unpack question

list(,$nfields) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; The question is, why "N*" if substr should return 4 bytes, and they will be unpacked as N? And why double assignment? UPD: This code is part of Sphinx native PHP connector. After some code hacking it became clear that this code extracts 4-byte integer. But logic ...

Showing specific categories

I'd like to show only specific wordpress categories (with their sub-categories nested), so for example: Main Category 1 Sub Category 1.1 Sub Category 1.2 Main Category 5 Sub Category 2.1 Sub Category 2.2 ... I can hardcode it inside the sidebar template, but I'd like to know if there's any existing plugin/widget that allows thi...

Reformat php date compare function

Hi again fellas! Found the following snippet online and are currently using it in my web application, however it returns time like "0:5:1". I would like it to format the output like a real date, ie: 00:05:01. Guess that there is an embarrassing quick solution to solve this. Here comes the snippet: function getTimeDifference($start, $e...

How to print posts and comments with only one sql query

Hi, Is it possible to print out (PHP) all my blog posts + associated comments via one sql query? If so, how? I was thinking in this direction: SELECT p.post_id, p.title, c.comment_body FROM posts p LEFT JOIN comments c ON c.parent_id = p.post_id But this didn't work out as I expected ...

Store IPv6 in database

What's the best practise to store IP's with PHP in MySQL database? There's a function called ip2long - but this is just for IPv4. But what about IPv6? I know a php function that is for IPv6 IP's, but it doesn't work on Windows with PHP < Version 5.3 ...

Subdomain read domain session

Hi .... I create two application, let say my first application called mastersite, and the second application called childesite. I store the childesite project under the mastersite project directory. I create virtual host in my apache server, and the document root of the directory point to masterproject directory supposed the virtual hos...

reflection or instantiation?

I want to determine if a class exists and whether or not it implements an interface. Both of the below should work. Which should be preferred and why? //check if class exists, instantiate it and find out if it implements Annotation if(class_exists($classname)){ $tmp=new $classname; if($obj instanceof Annotation) {//do somethi...

PHP date issue - strtotime does not output what it's supposed to?

Hi! I have a couple of blanks DATETIME values(0000-00-00 00:00:00) in my database. Whenever i run those through strtotime, they return "1263247058" instead of FALSE, which it should do according to the info on the linked page: http://stackoverflow.com/questions/1224680/php-strtotime-outputs-nothing How come? Thanks. ...

PHP: Nested Foreach loop problems

I am attempting to display a list of users based on a month value. I want to display January then all the users associated with it etc... What i have now is working correctly for the first months then does nothing after. I have comments in the code and a live version of this code is running at: http://blog.funeraldirectorslife.com/parti...

Tinyurl API Example - Am i doing it right :D

Hi ... we use super-long Hashes for the Registration of new Users in our Application. The Problem is that these Hashes break in some Email Clients - making the Links unusable. I tried implementing the Tinyurl - API, with a simple Call, but i think it times out sometimes ... sometimes the mail does not reach the user. I updated the Code...

PHP framework and CMS

Hey everyone, What is the difference between a PHP framework and a CMS? It just unclear to me what the difference is. Thanks! ...

PHP mysqli::autocommit VS "START TRANSACTION"

In our database layer object, we have always managed transactions with "START TRANSACTION", "ROLLBACK" and "COMMIT" SQL statements executed via mysqli::query. Doing some research today, I discovered this mention in the MySQL Manual regarding using API level calls to manage a transaction VS using straight SQL: Important Many API...

How do I recursively nest smarty {foreach} loops while still being able to use {$smarty.foreach.<loopName>.first/last}?

I have a Smarty template file in which I'm looping over hierarchical data represented by nested arrays. The child data is represented exactly the same way as the parent data, so I wanted to recursively {include} the Smarty template to render this: Source of "my.tpl": {foreach from=$children item="child" name="childrenLoop"} {* dis...

PHP __call equivalent for java

Is there a Java equivalent for the __call of PHP? It would make sense to me if that's not the case, because it would probably result in compiler errors. From the PHP manual on magic methods: __call() is triggered when invoking inaccessible methods in an object context. ...