php5

How do you find the last element of an array while iterating using a foreach loop in php ?

I am writing a sql query creator using some parameters. While doing that ,I came across this problem. In java , Its very easy to detect the last element of an array from inside the for loop by just checking the current array position with the array length. for(int i=0; i< arr.length;i++){ boolean isLastElem = i== (arr.length -1) ?...

File Upload using zend framework 1.7.4

I am trying to upload file using zend frame work but have not been successful. I have read Akras tutorial, which was helpful but when i used those techniques in my project I was not able to get it to work. ...

Fatal error: Class 'MySQLi' not found

I am doing a tutorial and getting this error: Fatal error: Class 'MySQLi' not found (LONG URL) on line 8 the code on line 8 is: $mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error()); I saw online someone said to to see if it was turned on in my Phpinfo() but there wasn't anything listed in there under f...

Trouble reading Windows Live Contacts Api results in php

I am using windows live contacts api to create find a friend functionality in a PHP 5 application. I am able to get the results fine but it's encoded "deflate". I have tried using gzuncompress to decompress but it returns false. If any one has experience using this api with php 5 and can help that would be great. ...

Access a static variable by $var::$reference

I am trying to access a static variable within a class by using a variable class name. I'm aware that in order to access a function within the class, you use call_user_func(): class foo { function bar() { echo 'hi'; } } $class = "foo"; all_user_func(array($class, 'bar')); // prints hi However, this does not work when trying to ...

imap_header, recent = N, unseen = ""... but I haven't read it yet!

Using PHP 5.2.0-8+etch13 on a LeaseWeb server, I have code that process a file emailed to a certain address by picking up the email via imap. I call imap_open (checking for errors and not finding any), get the number of messages via imap_num_msg, and look over then calling imap_header on each. All runs without errors. I then check if ('...

PHP: sort array by half-hour intervals

I have a very specific problem here. I have a multi-dimensional array that I want to sort first by half-hour time intervals, second by dates. The function array_multisort will not meet my requirements. Example: I want: array(array("time"=>"12:15", "date"=>"2009-03-24"), array("time"=>"12:10", "date"=>"20...

PHP: Parse a string to perform replacements

I have a group of text based rules that are structured like this: Rule 1: Do [XXX] when [PN] greater than [N] Rule 2: Get [PRD ..] and add [X.XX] To go with this is an array of data that translates each grouped code into a CSS class ID (for jQuery). I also have an array of translations from [code] to ID stored in a simple structured...

doe anyone know of a free tool or how to convert an rtf to a jpg

I have an RTF file that I need to display to a user. I know that I need to convert it if I want to display it in the browser. I would like to be able to convert it to JPG so that I can take advantage of other code that I am using that uses ImageMagick to convert JPG to PDF. ImageMagick will convert a PDF to a JPG, but not an RTF :( I...

Php 5 on RedHat Enterprise Linux 5

By default, RHEL5.x64 comes with 5.1.6 - pretty old. I'm looking for a more up to date version, 5.2.8, or even the latest 5.2.9 (as of March 2009). Ideally, a Yum/RPM-based solution, for transparent upgrades (when I plan). How do you upgrade the default for an up-to-date version? ...

Problem connecting to a Exchange 2007 server in PHP5 with imap_open.

When im trying to connect to an Exchange 2007 server over IMAP in PHP5 I get the following error message. Kerberos error: No credentials cache found (try running kinit) for smtp.domain01.net I was wondering if somebody found a way around this issue? Related info: http://bugs.php.net/bug.php?id=33500 ...

html to word in php (problem in open office output)

I have this simple code in php: <?php header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=kid_tag.doc"); echo '<table cellspacing="0" cellpadding="0" border="0" width="8.4cm"> <tr> <td colspan="3" style="text-align: right; height: 0.6cm">Nursery</td> </tr> <tr> <td ...

PHP5: Why is try/catch failing?

On my XAMPP/Win XP build, PHP5.2.3 fails to catch any exceptions. None of the examples work, and this: try { throw new Exception('Fail'); } catch (Exception $e) { echo 'Succeed'; } ...results in: Fatal error: Uncaught exception 'Exception' with message 'Fail' in M:\path\to\test.php:4 Stack trace: #0 {main} thrown in ...

$_GET without foo

How can I use download.php?get=file.exe with without the get variable, like download.php?=file.exe, using the $_GET in PHP? ...

PHP4 vs. PHP5

I have a site that is written completely in PHP4 - the supported version on my hosting at the time. After tons of time on this language, I've come to see that PHP5 has a lot of stuff that I think would be useful to me. Two questions: Would switching my hosting to PHP5 cause any serious damage to existing PHP4 scripting? Is PHP5 consi...

Why Use PHP OOP over Basic Functions and When?

There are some posts about this matter, but I didn't clearly get when to use Object Oriented coding and when to use programmatic functions in an include. Somebody also mentioned to me that OOP is very heavy to run, and makes more workload. Is this right? Lets say I have a big file with 50 functions, why will I want to call these in a cl...

How to Explode String Right to Left ?

$split_point = ' - '; $string = 'this is my - string - and more'; How can i make a split using the second instance of $split_point and not the first one. Can I specify somehow a right to left search? Best simple approach? Basically how do I explode from Right to Left. I want to pick up the last instance of " - ". Result I need: $ite...

Need sample XML-RPC client code for PHP5

Need a tutorial or some instruction on how to use the XML-RPC library built in to PHP (version PHP Version 5.2.6) for a XML-RPC client. The server is in Python and works. Google and php.net are failing me. Update: Per phpinfo I have xmlrpc-epi v. 0.51 installed. I visited http://xmlrpc-epi.sourceforge.net/ but the xmlrpc-epi-php exam...

PHP PDO: Differences between the methods of retrieving a single-column result.

What's the difference between $PDOStatement->fetchColumn(); and $PDOStatement->fetch(PDO::FETCH_COLUMN); (if one exists)? Or are they functionally similar but only aesthetically different? ...

Number Appears after Array Stored in SESSION

I'm doing a print_r on a array stored on a session variable and for some unknown reason it's adding a number after the array prints. Example: Array ( [0] => 868 [userid] => 868 ) 1 If I do a print_r directly in the function itself and before the variable gets stored on session variable, it doesn't add that number 1. Solution...