Development Articles
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDevelopment Articles

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 12th, 2001, 10:06 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Bravo - very helpful !

It's great to see an article that gives me a half-dozen things I can use immediately - great examples, too ! Thanks for one of the best things I've read on DevShed.

Reply With Quote
  #2  
Old November 13th, 2001, 01:43 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Nice, but no stack?

In 'push and pull', you do give the functions, array_pop, array_push etc, but you don't give where there really handy for:
stacks.
For the rest, good article, but I knew them all already.

Reply With Quote
  #3  
Old November 13th, 2001, 02:45 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Foreach

I'd like to also mention the 'foreach()' function, which proves incredibly handy when sorting through and applying operations on individual key/value pairs. Much more user friendly than 'array_walk()'. For more info check out "PHP.net's foreach() page":http://www.php.net/manual/en/control-structures.foreach.php

Reply With Quote
  #4  
Old November 13th, 2001, 04:22 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
gosh

Hello,
Excellent article that emphasises what I've been thinking for a while - if you want to do something in PHP, don't do it the convoluted manner you have to do in C or VB, there's bound to be a function to do it in PHP!

A couple of things though:
1. It would have been nice to see some multi-dimensional array stuff
2. It would have been nice to see array integration with mySQL
3. Arrays have tens of functions, as does most other areas of PHP, which is why halve of the PHP language is missed out by most people (probably more by me!). What is needed is PHP to evolve into a more object oriented language and, in the case of arrays, create have an array (and all other constructs, like databases, sessions, etc) as classes with all the functions as members.

Neil


Reply With Quote
  #5  
Old November 14th, 2001, 07:10 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Hoo-array

An excellant intro & advanced guide to php arrays !

Reply With Quote
  #6  
Old November 15th, 2001, 09:51 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Very Nice!

That was a very informative article, I especially liked the sort functions.

Hope to see more articles this in the future!

Reply With Quote
  #7  
Old November 17th, 2001, 01:21 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Excellent article!

Excellent article! Well written, easy to read, and very useful info! :)

Reply With Quote
  #8  
Old November 17th, 2001, 03:01 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
range()

Support for character sequences and decrementing arrays will not be available until version 4.1 <br>
(ie. $alphabet = range("a", "z"); )

The same goes for range(<i>high</i>, <i>low</i>).


Reply With Quote
  #9  
Old November 17th, 2001, 04:09 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
referencing arrays with curlies "{ }"

One can reference a hash/associative array using curly brackets. It removes the hassle of having to escape single quote marks used as apostrophes or to concatenate the string with an array.

For example:

$requests = array(
"Lion" => "courage",
"Scarecrow" => "brain",
"Tin Man" => "heart",
"Dorothy" => "home");

echo "The Wizard of Oz agreed to grant the Tin Man a {$requests["Tin Man"]}.";

echo "The lion's request was to gain {$requests['Lion']}.";

Reply With Quote
  #10  
Old November 17th, 2001, 04:26 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Good Job!

The functions you covered in this article will be very helpful to me. The book from which I learned PHP gave me a good, workable knowledge of the language, but didn't go into this much detail with arrays. Thanks for the added insight!!

Reply With Quote
  #11  
Old November 17th, 2001, 08:10 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
"" is not null

In the example for array pad() the second comment says that $students = array_pad($students, 4 ""); will return an array containing 4 <i>null</i> values.
Instead, it will return an array containg 4 EMPTY values which is not the same thing.

$students = array();<br>
$students = array_pad($students, 4, "");<br>
echo isset($students[0])? "isset TRUE<br>" : "isset FALSE";<br>
echo empty($students[0])? "empty TRUE<br>" : "empty FALSE";<br>
echo is_null($students[0])? "isnull TRUE " : "isnull FALSE";<br>

what makes it confusing is that PHP returns true when comparing an empty string with NULL:

$a = "";
$b = NULL;
echo $a == $b ? "true" : "false";
/* yes it does return TRUE because $a is converted to NULL in the process of equality comparison */
echo $a === $b ? "true" : "false";
/* but $a is not identical to NULL, that is why the identity comparison returns FALSE */

echo is_null($a) ? "true" : "false";
// returns FALSE<br>
echo is_null($b) ? "true" : "false";
// returns TRUE

Reply With Quote
  #12  
Old November 20th, 2001, 12:53 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
dsa

how are u?

Reply With Quote
  #13  
Old November 20th, 2001, 10:33 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Mega Thanks!

Mega Thanks to you! I have been working with php for 3 months trying to get some code out. I didn't have time to play with all thoes functions! They have DRAMATICALLY increased efficiency in my code!! You are a God send for writhing this article! This article was written very clearly and easy to follow!!

Thanks,
Ariel

Reply With Quote
  #14  
Old November 25th, 2001, 03:40 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Very Comprehensive

Didn't realise how many options you had with PHP to enable array manipulation.

Thanks heaps

Reply With Quote
  #15  
Old December 6th, 2001, 02:31 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Great

This was just what I was looking for, keep up the good work









----------------------
http://www.webhostgold.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDevelopment Articles > Array Manipulation With PHP4


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT