 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPBuilder.com: PHP Arrays Advanced Iteration and Manipulation
by Chris Cornutt December 09, 2011 @ 12:50:11
In this new tutorial from PHPBuilder.com, Jason Gilmore shows you some of the more advanced things you can do with arrays in PHP (specifically in the areas of iterating through them and manipulating their contents).
Sporting more than 70 native array-related functions, PHP's array manipulation capabilities have long been one of the language's most attractive features. [...] There are however many array-related tasks which ask a bit more of the developer than merely knowing what part of the manual one needs to consult. Many such tasks require a somewhat more in-depth understanding of the native features, or are possible only when a bit of imagination is applied to the problem.
In his examples he shows how to do things like sorting a multi-dimensional array, iterating recursively (with the help of a RecursiveArrayIterator), converting an object to an array and doing "natural" sorting on an array's contents.
voice your opinion now!
array manipulation advanced iteration spl recursive sort
Davey Shafik's Blog: DateTime Timestamp Parsing
by Chris Cornutt September 20, 2011 @ 11:24:27
In a new post to his blog Davey Shafik looks at parsing dates with DateTime, the new and improved way to handle dates in PHP (well, not so new but definitely improved).
As part of a recent project, I was tasked with taking timestamps returned by an API and displaying fuzzy dates in the final output (e.g. 3hrs ago, in 2 weeks, tomorrow). The timestamp format in question looks like: 2012-09-01T16:20:01-05:00 This format can be found in PHP as the DATE_ATOM or DateTime::ATOM constants, which contain the date() formatter string: Y-m-dTH:i:sP With this in hand, we can now easily parse the timestamp into a useful object.
Parsing the date into a DateTime object is as easy as giving it the date string and telling it how it's formatted. Then you can do all sorts of fun things. He shows how to shift the timezone by name, by time increment - simple (like "1 hour") and more complex (like "1 hour 5 minutes 3 seconds"). You can find out more about the DateTime object in the PHP manual.
voice your opinion now!
datetime parsing manipulation tutorial
PHPBuilder.com: 10 PHP Tricks for Associative Array Manipulation
by Chris Cornutt December 13, 2010 @ 11:54:34
On PHPBuilder.com there's a new tutorial with ten handy tips you can use to work with associative arrays in your PHP applications.
The associative array -- an indispensable data type used to describe a collection of unique keys and associated values -- is a mainstay of all programming languages, PHP included. [...] Such extensive support can be a bit overwhelming to developers seeking the most effective way to manipulate arrays within their applications. In this article, I'll offer 10 tips that can help you shred, slice and dice your data in countless ways.
His tips include working with the arrays by:
- Adding Array Elements
- Swapping Keys and Values
- Editing Array Values
- Randomizing Array Order
- Searching the Array
voice your opinion now!
associative array manipulation tutorial
PHPBuilder.com: 10 Easy Solutions for PHP String Manipulation
by Chris Cornutt June 03, 2010 @ 10:04:32
If you're relatively new to the PHP language and want a few handy tips on working with strings, you should check out this list of ten things that Jason Gilmore has put together to help you with some common string manipulations.
PHP's capabilities [string manipulation] are so strong that it can sometimes be difficult to determine the best possible approach for accomplishing a particular string-related task. In this article I highlight the ideal solutions to 10 common string manipulation tasks.
Among the methods in his list of transformations, he includes:
- Truncating Text to Produce a Summary
- Parsing a CSV File
- Converting URLs into Hyperlinks
- Converting Newline Characters to Break Tags
voice your opinion now!
string manipulation tutorial introductory
Michael Maclean's Blog: Handling fonts in PECL/Cairo
by Chris Cornutt March 02, 2010 @ 12:42:43
Michael Maclean has a look at working with fonts in Cairo (a graphics manipulation extension in the PECL repository). The example will be added to the PHP manual too in case you need it for reference later.
Currently, in PECL/Cairo the only way to draw text is the referred to as the "toy" text API, which is a very basic way of handling text compared to the facilities available in the Cairo library itself. However, it's sufficient for most purposes that I've come across so far.
With the first versions of the Cairo extension, you had to use the selectFontFace method to choose the font you wanted. With the introduction of Cairo 0.2.0, you can now use FreeType font support instead and can use the streams API built into PHP to locate the resource. A snippet of code is included to show how that would work.
voice your opinion now!
cairo graphic manipulation extension font freetype
Sameer Borate's Blog: Easy manipulation of URLs
by Chris Cornutt November 10, 2009 @ 12:48:49
On his codediesel.com blog today Sameer Borate has a quick post looking at URL manipulation with the help of the Net_URL2 PEAR package.
Whether you are dynamically creating urls or changing existing ones, manipulation of urls is a frequent coding requirement during development; doing the same on short urls is easy, but quickly becomes complex for urls which have larger query parameters.
He shows how to use the package to parse the current URL into its respective parts (host, port, path, etc) and how to automatically change certain parameters in the current URL and push the updated version back out the other side. There's also a bit there at the end on normalizing URLs.
voice your opinion now!
url manipulation pear neturl2 package
Kae Verens' Blog: php and jquery chp7 image manipulation
by Chris Cornutt July 20, 2009 @ 09:17:48
Kae Verens has a new post to his blog looking at a form of non-destructive image manipulation - using the URL of the request to determine the changes that need to be made.
The solution is to not actually create copies, but to record the changes applied to the original image in the URL of your manipulated image. When the server is asked for those URLs, it runs the manipulations on the original image and gives you back the new image. Of course, we will cache the new manipulations so this doesn't need to be done every time, but this now allows you to replace the original image, then clear the cache, forcing all the variants of it to refresh, without you needing to do it again.
A demo of the script in action is included in the post as well as a link to download the script doing the work.
voice your opinion now!
cache url manipulation image
Debuggable Blog: String substitution using UUIDs
by Chris Cornutt August 22, 2008 @ 12:04:39
On the Debuggable blog, Felix Geisendorfer shows how to create a string parser that allows you to pull out parts of the string you don't currently want manipulated to be put back later.
If you've ever written any non-trivial String processing code, you've probably ran into the situation where you wanted to exclude certain parts of your string for a certain operation. Usually that would mean you have to tokenize your string, or adjust the operation you want to run so it doesn't affect the part of the string you want to exclude from it. Both of those solutions can be fairly time intensive so I was looking for a shortcut and found one.
He provides the code for this string substitution class, a method substitute() that matches based on a regular expression and, if found, stores the parts for later use.
voice your opinion now!
string substitution uuid manipulation regularexpression
DevShed: Building an Image Generator Class with PHP 5
by Chris Cornutt October 01, 2007 @ 12:57:00
In a new tutorial today from DevShed, they introduce you to one of the more powerful bits of PHP functionality - the graphics manipulation functions - and how to use them to create an image generator class in PHP5.
In simple terms, over the course of this brand new PHP series, which will be comprised of three friendly tutorials, I'll walk you through the development of an easy-to-follow PHP class that will have the ability to build dynamic text strings, which will be outputted straight to the browser in the form of image streams.
This part part of the series lays the foundation, creating the basic structure of the class and the buildImageStream and displayImage methods. This is then used in a sample use - creating images, white text on a black background.
voice your opinion now!
tutorial gd image manipulation generator class php5 tutorial gd image manipulation generator class php5
|
Community Events
Don't see your event here? Let us know!
|