php

Multithreaded Programming in PHP to avoid runtime limitations.

I know about PHP not being multithreaded but i talked with a friend about this: If i have a large algorithmic problem i want to solve with PHP isn't the solution to simply using the "curl_multi_xxx" interface and start n HTTP requests on the same server. This is what i would call PHP style multithreading. Are there any problems with thi...

PHP Array and ArrayObject

which one should be used to manipulating data, Array or Array Object? Like search,sort and other array manipulations. ...

gzdeflate() and large amount of data

I've been building a class to create ZIP files in PHP. An alternative to ZipArchive assuming it is not allowed in the server. Something to use with those free servers. It is already sort of working, build the ZIP structures with PHP, and using gzdeflate() to generate the compressed data. The problem is, gzdeflate() requires me to load ...

Parsing XML file through PHP while using XSLT as the main template file.

I have a lots (500ish) xml files from An old ASP and VBscript that was running on an old windows server. The user could click a link to download the requested xml file, or click a link to view how the xml file will look, once its imported into their system... If clicked to view the output, this opened a popup window were the xml filena...

Include the result of a Foreach loop in a variable in PHP ? ( for the function mail() )

Hi, I'm French so I maybe not speak english very well. I'm trying to "put" the result of a foreach loop in a varible like that : $msg = '<html><head> <title>Commande de photos</title> </head><body> <p>Voici la liste des photos demand&eacute;es :<br /> <ul> HERE I WANT TO "PUT" THE RESULT OF THE FOREACH LOOP</ul>'; H...

php fsockopen unable to connect, connection timeout error

Hello, I am running a local apache server on an ubuntu machine, and i am trying to use the phpmailer class to send mail. It tries to connect by fsockopen to the mail server, but it throws a timeout error. I tried setting the timeout to 15sec with no luck. It does work on other machines. How can i find out if my ISP has blocked requests...

Using $ variables in preg_replace in PHP

Ummm... how do I use variables in a call to preg_replace? This didn't work: foreach($numarray as $num => $text) { $patterns[] = '/<ces>(.*?)\+$num(.*?)<\/ces>/'; $replacements[] = '<ces>$1<$text/>$2</ces>'; } Yes, the $num is preceeded by a plus sign. Yes, I want to "tag the $num as <$text/>". ...

mySQL LIKE query

Hello, I am trying to search my db for a string. But it should be able to match any word and not the whole phrase. Suppose table data has text like "a b c d e f g". Then if I search for "d c b" it should be able to show the results. field LIKE '%d c b%' does not work like that Can someone suggest a more robust way to search, possible...

root path doesnt work with php include .

Hi. / in the beginning of a link to get to the root folder doesnt work in php include. for example "/example/example.php" What is the solution? ...

In Cakephp using a helper to set template variables

Is it possible to set a template variable in a helper? Ultimately what I'm trying to do is have a helper add in code to the header of the layout, for use with javascript and such. Ways I can think of that I'd prefer not to use: Passing in the view object: don't want to worry about having to call an extra function using the "global" k...

Optimize regex replace in PHP

I have written a PHP function to take a video embed code that has width and a height and allow you to specify a new width. The function will then scale down the height using the appropriate scaling factor. I discovered that the width and height were not always adjacent so I make a couple of calls which I have a hunch are unnecessary. Is...

PHP/MySQL - SELECT various tables, with some row name

Hi, Which is the best aproach to select * from various tables but with same row name, cause normally i use $row['name'] but i have seven tables with the some name... how can i do this? tkz Roberto ...

how can I make a .pdf file using php?

i have this letter where in some parts will be filled-up by the user. like this: I am <input name="age" type="text"> years old. is it possible to save the letter into a .pdf file? ...

Weeknumber print date out

Hallo all. if i have week number 42 and i need to know what dates there are in this week, can sombardy maby tell me a easy way to get this info? tanks a lot :) ...

Moving array items around

Here's my array: [2555] => Array ( [0] => stdClass Object ( [meta_id] => 1246 [post_id] => 2555 [meta_key] => event_date [meta_value] => Sept 24th - 29th ) [1] => stdClass Object ...

Easiest way to grab filesize of remote file in PHP?

I was thinking of doing a head request with cURL, was wondering if this is the way to go? ...

Getting an OOP PHP calendar app to update two tables at once.

I'm building a PHP calendar app for a photography group. They need to be able to assign multiple dates/times to a single event. As of now, I have an Events table and a Slots table (for time slots). Events only has id, title, and description, while Slots has id, start time, end time, and event_id as a foreign key. I've created an Event ...

css/php: how to solve this div float problem / odd even loop in array

My code is at the end of this post. How on earth do i get "box 3" to aligh next to "box 1" OR to the content inside "box 1" instead of aligning itself at the end of "box 2". The important thing here is that all four boxes MUST use the same style - (style 2) as it's being used in an called by an array. Here is what it is now and what i...

Remove non-utf8 characters from string

Hello folks, Im having a problem with removing non-utf8 characters from string, which are not displaying properly. Characters are like this 0x97 0x61 0x6C 0x6F (hex representation) What is the best way to remove them? Regular expression or something else ? ...

Retrieving dependent/parent from within domain entity method

How would one go about retrieving a dependent/parent object from an entity. $person->getAddress(); This should retrieve the Address object for that person from the database and return it as an object. Is this a good way to do it and how should the code look like if this is ok to do. Doing this would mean that the object itself should...