Use PHP functions in JavaScript

JavaScript chop

!No description available for chop. @php.js developers: Please update the function summary text file.

1
2
3
4
56
7
8
9
1011
function chop (str, charlist) {
    // !No description available for chop. @php.js developers: Please update the function summary text file.
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/chop    // +   original by: Paulo Freitas
    // -    depends on: rtrim
    // *     example 1: rtrim('    Kevin van Zonneveld    ');
    // *     returns 1: '    Kevin van Zonneveld'
    return this.rtrim(str, charlist);}
external links: original PHP docs | raw js source

Examples

Running

1
rtrim('    Kevin van Zonneveld    ');

Should return

1
'    Kevin van Zonneveld'

Dependencies

In order to use this function, you also need:

Open syntax issues

php.js uses JsLint to help us keep our code consistent and prevent some common bugs.

Eventually we want all code to pass or at least take into consideration most fixes suggested by JsLint, following this JsLint configuration we’ve decided on.


Authors

Thanks to the following developers, you get to have chop goodness in JavaScript.

Comments

Add Comment
Use:
[CODE]
your_stuff('here');
[/CODE]
for proper code formatting
By submitting code here you are allowing us to use it in php.js hence dual licensing it under the MIT and GPL licenses

Gravatar
Kevin van Zonneveld
10 Dec '08 Permalink

q  @ Paulo Ricardo F. Santos: Indeed, let's save us some wasted bytes there. changed.

Gravatar
Paulo Ricardo F. Santos
4 Dec '08 Permalink

q  @ Kevin: Hmm, now I see that there's no need to send null if charlist is undefined, rtrim() itself should avoid any problems. ;)


Contribute a New function