php

preg_replace() str_replace() apostrophe nightmare! - Drupal menu image replace

Can anyone help me decode why this doesnt work? $cssid = preg_replace("/'/", "", $cssid); Trying to strip the single quote marks from some html... Thanks! H EDIT This is the full function - it's designed to rebuild the Drupal menu using images, and it applies CSS classes to each item, allowing you to select the image you want. Str...

how to match this type of construction?

im doing parsing and the kind of text that i want to match and then make it null is as follows :- <tr class="label-BGC"><td colspan="4">any kind of text here</td></tr> i want to match every line that contains "<tr class="label-BGC"><td colspan="4">any text</td></tr>" its evening here and my brain-battery is totally down what im try...

Automatically trimming a mp3 in PHP

Are there any ways to automatically trim an MP3 uploaded to a website to 30 seconds (or some other length) in PHP? If not, is there any good 3rd party services that could be integrated (transparently to the user) to achieve the same effect? Thanks. ...

[phpunit] mock newly created instance?

hi i have old code which didnt use TDD now i want to write a test for a function which looks like this function somefunction($someargs){ // do a few checks on $someargs $database = new DB_PG(); $result = $database->select($query); // do some changes on result return $result; } since im not much expirienced with ph...

Find phrases/words between HTML using PHP

Hey all! I was wondering of a solid way to find phrases/words that are part of an HTML document. For example if I have the following document: <a href="#">This is a test</a><b>Another test</b> My goal is to find "This is a test" and "Another test" and replace it with something else. Note that these are sample phrases and it could con...

split <b>'s in php

For this code i need to take a string like <b>hey</b> more text<b>hey2</b> other text and i expect the returned array to look like <b>hey</b> more text <b>hey2</b> other text However it doesnt. How do i make it look like the above? my test code is $myArr = split("<b>", "<b>hey</b> more text<b>hey2</b> other text"); foreach($myArr ...

Array to create dates

I want to create an array using PHP that can be used in MySQL. My query looks like this... select name, sum(if (tdate='2009-09-09', amount, 0) as day1, sum(if(tdate='2009-09-10', amount, 0) as day2 ... ... sum(if(tdate='2009-10-01', amount, 0) as day23 from revenue group by name; The date range may change but ...

What's the most elegant method for determining if an array is associative or not?

I have some code that may be passed either an indexed array of values, or an associative array of value pairs. (The parameter is then used to construct radio buttons.) What's the most elegant (least resource hungry?) method for determining which I have? EDIT: One slight problem with this: what if the array to be tested is as follows.......

PHP SOAP fread() dynamic POST size

Looking to read the file size of the SOAP POST, any best practices? $data = fopen('php://input','rb'); $content = fread($data,5000); $dom = new DOMDocument(); $dom->loadXML($content); Would like the 5000 to be dynamic as each SOAP POST size will be different or does this matter? Using fread() would be great ...

accessing DELETE from jquery in PHP

If I am sending data from my ajax request as type:delete How do I then access it on my php page instead of $_GET or $_POST ? ...

PHP - Multi dimensional SESSION array a good or bad idea for performance?

Are there any reasons not to want to use a multi dimensional SESSION array to store temporary user data? ...

Apache's mod_php OR FastCGI? Which is good for Wordpress?

Hi guys, I have basic idea about running PHP in different configurations like mod_php, cgi, FastCGI, etc. In my findings and test I found FastCGI is slightly better. I like FastCGI's support for SuEXEC most. Wait I do not want to get into benchmarking business here again. If you surf web, you will find people proving one way is faster ...

Matching contents inside php tags using regex

Hi, I have some trouble matching the contents inside php tags. Currently I have this code, but it's not working for me: <?php preg_match_all('/<\?php(.+)\?>/', $str, $inside_php); ?> I need to retrieve the contents so I can do other things with them, like eval(). ...

PDO do not run same queries twice?

Good day! I'm trying to run the same update statement with the same params twice and it seems that it is not executed in the second case: $update_query = $this->db->connection->prepare('UPDATE `Table SET `field` = :price WHERE (`partnum` = :partnum)'); $update_query->execute(array('price' => 123, 'partnum' => test)); var_dump($update_...

Drupal - How can I change the default image node settings?

Hiya, I'm using Drupal 6, Image and NodeAsBlock, and I'm trying to link my nodes into pages. That all works, but each time I link an image I get by default: Title Thumbnail image size No hooks to help me style it in css Is there a way I can get around this? I really want to just upload an image, click the "create block" textbox and...

PHP: How to draw an image over another image?

I am using PHP & GD library. I want to draw an image (say this one: http://www.gravatar.com/avatar/107f2fafb2d29fedc3783b141139a878?s=128&amp;d=identicon&amp;r=PG) over another image: http://www.geekpedia.com/gallery/fullsize/simplistic-windows-wallpaper.jpg at specified coordinates (top-left or top-right or anywhere in the image). How...

SSO between Liferay 5.2 and PHP through CAS

I'm trying to use CAS for SSO between Liferay and a PHP webapp. I installed JASIG CAS webapp, created a certificate with keytools and configured Liferay through its administrative GUI (Setting>Authentication>CAS tab) as follows: When I click on "Sign in" in Liferay menu I'm forwarded to the CAS login page (with the "dirty trick" user...

Creating a back link using Yii Framework?

I need to know how to create a back link in the action view of the Yii Framework. I want to use CHtml::link('Back',Yii::app()->request->urlReferrer); but this somehow just does not want to work? Quite new to this Framework. ...

Send some arguments to a PHP using the iPhone

Hi I need to send some arguments from the iPhone to a php in the server PHP: $text = $_GET['text']); $mail = $_GET['mail']); $phone = $_GET['phone']); iPhone SDK NSString *text = [[NSString alloc] initWithString:@""]; //very long text NSString *mail = [[NSString alloc] initWithString:@"[email protected]"]; NSString *phone = [[NSString all...

Wordpress problem language

okay on our testing server the language works fine whetter your click it twice or more but when transffered onto the clients server bugs occured... to see the bug click on "FR" top left (it's now on French) once click on "EN" (it stays in french click it again and it gives you a page with no style saying page not found) . I've been over ...