PageRenderTime 25ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/website/source/php/strings/split.html

http://github.com/kvz/phpjs
HTML | 38 lines | 37 code | 1 blank | 0 comment | 0 complexity | cde6d30a6e1257e1d8443214ea2f0ba2 MD5 | raw file
  1. ---
  2. warning: 'This file is auto generated by `npm run web:inject`, do not edit by hand'
  3. examples:
  4. - 'split('' '', ''Kevin van Zonneveld'')'
  5. returns:
  6. - '[''Kevin'', ''van'', ''Zonneveld'']'
  7. dependencies: []
  8. authors:
  9. original by:
  10. - 'Kevin van Zonneveld (https://kvz.io)'
  11. notes: []
  12. type: function
  13. layout: function
  14. title: PHP's split in JavaScript
  15. description: >-
  16. Heres what our current JavaScript equivalent to <a
  17. href="https://php.net/manual/en/function.split.php">PHP's split</a> looks
  18. like.
  19. function: split
  20. category: strings
  21. language: php
  22. permalink: php/strings/split/
  23. alias:
  24. - /functions/php/split/
  25. - /functions/strings/split/
  26. - /php/split/
  27. - /functions/split/
  28. ---
  29. {% codeblock lang:javascript %}module.exports = function split (delimiter, string) {
  30. // discuss at: https://locutus.io/php/split/
  31. // original by: Kevin van Zonneveld (https://kvz.io)
  32. // example 1: split(' ', 'Kevin van Zonneveld')
  33. // returns 1: ['Kevin', 'van', 'Zonneveld']
  34. const explode = require('../strings/explode')
  35. return explode(delimiter, string)
  36. }
  37. {% endcodeblock %}