php

ZF: Using setObjectKey in partialLoop for only specific partials

I've figured out how to get models into partialLoops using the setObjectKey method of the PartialLoop helper. What I'm wondering if there is a way to specify that specific partial loops use the model key and other ones don't. Right now I think I have to do something like this: // sets the object key for ALL partialLoops $this->partialLo...

given 2 urls, how to tell that they are actually referring to the same website or webpage?

i am using Php. given 2 urls like this, http://soccernet.com and http://soccernet.espn.go.com/index?cc=4716 how to tell that they are actually the same? also consider situation where the difference is the httpS, like https://gmail.com and http://gmail.com please advise. I am finding it a struggle at using regex because sometimes it ...

Joining 2 XPath Queries

I'm having a hard time with XPath here.. Given the following XPath queries: $xpath->query('//input[@name="' . $field . '"]'); $xpath->query('//select[@name="' . $field . '"]'); Is is possible to combine them into one single query? I want to get the value of the field, however I don't know if the field with be a input, select, textarea...

Post a JSON object to server using PHP & Jquery

I have a JSON object: [{"song_id":"17382","title":" Revolution","song_viewed":"6","FK_genre_id":"11","artist_id":"190","artist_name":"Crematory","album_id":"1507","album_name":"Revolution"},{"song_id":"17377","title":"Reign Of Fear","song_viewed":"6","FK_genre_id":"11","artist_id":"190","artist_name":"Crematory","album_id":"1507","album...

Another PHP regex question

Guys, this probably will be fairly simple, but how am I able to find all the matches using regex of this occurrence in a load of text. [[data in here]] EG: Blah blah blah [[find]] and maybe [[this]] So I am able to find the occurrences and then replace them as urls. Does that make sense? I tried using preg_match_all("/[[([^<]*)]...

PHP - How can I get a new line in a textarea?

I have a textarea that I need to put a new line into with some dashes above. I have tried nl2br but that just echos the tag. I have also tried to concat the "\n" but it is ignored. What this is for is an email like system. When the user replies to an email, I want the old message below with a seperator like a few dashes. I can't get th...

integrating php mysql and voip and text to speech

Im looking for a starting point of writing an application that will allow a php/mysql program to interact with a VOIP caller(s). The idea is caller calls into a number, and that number reads text output from php/mysql based on menu options on the call. Where do i start with this project? Specifically, getting the voip to interact with ...

MySQL replication speed

Lets say we have 3 servers on a local area network: APP - php app server MASTER - master Mysql db server SLAVE - slave Mysql db server (replicating MASTER) In the one code block (php) APP inserts into MASTER, retrieving the last_insert_id which it then uses to select the data it just inserted from SLAVE. So the question is, will the...

adding 1 day to a DATETIME format value

In certain situations I want to add 1 day to the value of my DATETIME formatted variable: $start_date = date('Y-m-d H:i:s', strtotime("{$_GET['start_hours']}:{$_GET['start_minutes']} {$_GET['start_ampm']}")); What is the best way to do this? ...

Setters/Getters, Visibility [ OOP ] in PHP

I'm in the process of reformatting my class ( seen below ) - I think I made the mistake of setting everything with the same visibility in my class, whereas properties should really be private and getters/setters should be public in most cases. To grab a property I just do $path->propertyname but I've noticed its more practical to have s...

trying to figure out how to write this with arrays

here is the code im having trouble with $key = array( "0" => "sss", "1" => "wst", "2" => "sfv", "3" => "lac", "4" => "sgv", "5" => "lgb", "6" => "ant" ); $urls = array( "0" => "http://www.sarmenhb.com/index.php?key=", "1" => "http://www.navidoor.com/index.php?key=", "2" => "http://www.worldexchange.com/index.php?key=", "3" => "http://w...

Escaping using slashes and then using stripslashes PHP

In my code i am using addslashes to escape certain characters while inserting them into the database and when i send some information out i use stripslashes to remove those slashes, the situation is stripslashes function removes all the slashes so if i need to send any string which has backslashes those also get removed. How can i retain...

Integrating my PHP code into my site.

I did my programming before integrating into a design and I have to admit I am quite stuck on the whole situation. Here is my structure: System Files Admin (Admin files) Functions (Admin Function folder) User (User Files) Functions (User Function folder) Normal Visitor Account Files ( In system files folder). This whole direct...

extracting hour value from a DATETIME format

How would I get the hours from a DATETIME format variable. Example: 2009-08-17 13:00:00 And I just need to get '13' ...

Is there a way to place a '>' sign at the beginning of a line using PHP?

If I have a textarea like the one I'm using to type this message. I would like to append or concat a '>' to every line that breaks. The problem I am having is that I don't know where the lines break. What I want to do is emulate an email message when someone replies, they see '>' appended to every line. Is there a function for this? Tha...

PHP Regex match all HTML tags

I am reading contains of an HTML page for some details, I'm searching for every occurrence of a string, that string comes withing a tag, I want to read just that string only. Example: <a href="http://www.example.com/search?la=en&amp;q=javascript"&gt;javascript&lt;/a&gt; <a href="http://www.example.com/search?la=en&amp;q=PHP"&gt;PHP&l...

How to efficiently insert elements after another known (by key or pointer) element in a PHP array ?

Given an array: $a = array( 'abc', 123, 'k1'=>'v1', 'k2'=>'v2', 78, 'tt', 'k3'=>'v3' ); With its internal pointer on one of its elements, how do I insert an element after the current element? And how do I insert an element after a key-known element, say 'k1'? Performance Care~ ...

Is it possible to use smarty functions outside the smarty template?

If in a php file you had: $smarty->assign('content','<p>This is some test content</p>'); and in a template file I hadb (just for example purposes): <html> <head></head> <body>{$content}{config_load file='settings.conf'}{#setting1#}</body> </html> Would it be possible to load the setting from the config file, from the php file inste...

How do I append an array to another array in PHP?

I have two sequential (non-associative) arrays whose values I want to combine into a new array, ignoring the index but preserving the order. Is there a better solution (i.e. an existing operator or function) other than do the following: $a = array('one', 'two'); $b = array('three', 'four', 'five'); foreach($b as $value) { $a[] = $v...

PHP stripslashes problem

I have a development machine that is local and a server out on the net. Weird thing is that when I use stripslashes on my development machine, all slashes are removed and when I upload the same code to the net server, I see the escape character even though I am using stripslashes. Anyone have any ideas? ...