/website/source/php/strings/split.html
HTML | 38 lines | 37 code | 1 blank | 0 comment | 0 complexity | cde6d30a6e1257e1d8443214ea2f0ba2 MD5 | raw file
- ---
- warning: 'This file is auto generated by `npm run web:inject`, do not edit by hand'
- examples:
- - 'split('' '', ''Kevin van Zonneveld'')'
- returns:
- - '[''Kevin'', ''van'', ''Zonneveld'']'
- dependencies: []
- authors:
- original by:
- - 'Kevin van Zonneveld (https://kvz.io)'
- notes: []
- type: function
- layout: function
- title: PHP's split in JavaScript
- description: >-
- Here’s what our current JavaScript equivalent to <a
- href="https://php.net/manual/en/function.split.php">PHP's split</a> looks
- like.
- function: split
- category: strings
- language: php
- permalink: php/strings/split/
- alias:
- - /functions/php/split/
- - /functions/strings/split/
- - /php/split/
- - /functions/split/
- ---
- {% codeblock lang:javascript %}module.exports = function split (delimiter, string) {
- // discuss at: https://locutus.io/php/split/
- // original by: Kevin van Zonneveld (https://kvz.io)
- // example 1: split(' ', 'Kevin van Zonneveld')
- // returns 1: ['Kevin', 'van', 'Zonneveld']
- const explode = require('../strings/explode')
- return explode(delimiter, string)
- }
- {% endcodeblock %}