Module: PhpRuby::Array::Functions

Extended by:
Functions
Included in:
Functions
Defined in:
lib/php_ruby/array/functions.rb

Instance Method Summary collapse

Instance Method Details

#array_merge(*php_arrays) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/php_ruby/array/functions.rb', line 5

def array_merge(*php_arrays)
  result = Hash.new

  php_arrays.each do |pa|
    if pa.class == ::Hash
      pa.each{ |index, item| result[index] = item}
    elsif pa.class == ::Array
      pa.each_with_index { |item, index| result[result.count] = item }
    else
      fail(ArgumentError.new("#{__method__} can't handle argument of type #{pa.class}"))
    end
  end

  result
end

#explode(string, sep, count = 0) ⇒ Object



21
22
23
# File 'lib/php_ruby/array/functions.rb', line 21

def explode(string, sep, count = 0)
  string.split(sep, count)
end