-
Array Functions
There are a few fundamental differences when working with arrays in PHP and Ruby. PHP uses the versatile
arraydata type to handle both numerically ordered collections and associative key/value pair collections. Ruby uses two different objects —Arrayfor ordered collections, andHashfor associative style collections.In many of the array function examples we interchangeably use both Ruby arrays and hashes to display the closest Ruby equivalent.
It is important to note that hashes in Ruby are unordered collections. If the order of elements is important to the operation, you will need to use Ruby arrays.
Table of Contents
- array
- array_change_key_case
- array_chunk
- array_combine
- array_count_values
- array_diff
- array_fill
- array_fill_keys
- array_filter
- array_flip
- array_key_exists
- array_keys
- array_merge
- array_pop
- array_product
- array_push
- array_rand
- array_reverse
- array_shift
- array_sum
- array_unique
- array_unshift
- array_values
- count
- current
- each
- end
- in_array
- key
- list
- next
- pos
- prev
- range
- reset
- shuffle
- sizeof
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

