PageRenderTime 56ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/andriuspetrauskis/phpjs
HTML | 38 lines | 37 code | 1 blank | 0 comment | 0 complexity | 719139ca4d1d929e715edb7cf5834337 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. estarget: es5
  6. returns:
  7. - '[''Kevin'', ''van'', ''Zonneveld'']'
  8. dependencies: []
  9. authors:
  10. original by:
  11. - 'Kevin van Zonneveld (http://kvz.io)'
  12. notes: []
  13. type: function
  14. layout: function
  15. title: PHP's split in JavaScript
  16. description: >-
  17. Heres what our current JavaScript equivalent to <a
  18. href="http://php.net/manual/en/function.split.php">PHP's split</a> looks 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: http://locutus.io/php/split/
  31. // original by: Kevin van Zonneveld (http://kvz.io)
  32. // example 1: split(' ', 'Kevin van Zonneveld')
  33. // returns 1: ['Kevin', 'van', 'Zonneveld']
  34. var explode = require('../strings/explode')
  35. return explode(delimiter, string)
  36. }
  37. {% endcodeblock %}