Skip to content

Add Arr method: toLocaleString() #15

Description

@roberto-butti

What

Add new method to Arr class, in src/Arr.php file

Description

The toLocaleString() method returns a string representing the elements of the array. The elements are converted to Strings using their toLocaleString methods and these Strings are separated by a locale-specific String (such as a comma “,”).
In PHP as far as I know there is no toLocaleString. My suggestion is to try to convert into locale string detecting the type

  • number_format() if number
  • date_format if it is date

see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString

Checklist

  • implement method
  • write phpdoc for the function
  • write test in tests/ArrTest.php
  • execute composer format
  • execute composer test-coverage
  • check if your method has full test coverage
  • add method in changelog
  • update doc/arr.md adding a use case of the new method
  • update cheatsheet (examples/cheatsheet.php)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions