implode

  • Joining array elements using a string is done in Ruby using the Array#join method.

    PHP

    $result = implode('; ', array('derek@example.com', 'mike@example.com'));
    var_export($result);
    // => 'derek@example.com; mike@example.com'

    Ruby

    p ['derek@example.com', 'mike@example.com'].join("; ")
    # => "derek@example.com; mike@example.com"

    see also

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.