Skip to content

longbill/urlencode-for-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP style query string encoder in Node.JS

NPM

npm install urlencode-for-php --save

Usage

var urlencode = require('urlencode-for-php');

var data = {a:[1,2,3,4]};
console.log( urlencode(obj) );
// will output 'a[0]=1&a[1]=2&a[2]=3&a[3]=4'
var obj = 
{
	"a":"b", 
	c: [ 1, 2, 3 ], 
	d:
	[
		{ arr: ["+-X&?",2] },
		{ arr: [3,4] }
	]
};
console.log(urlencode(obj));
// will output: 'a=b&c[0]=1&c[1]=2&c[2]=3&d[0][arr][0]=%2B-X%26%3F&d[0][arr][1]=2&d[1][arr][0]=3&d[1][arr][1]=4'

License

MIT

About

encode object/array to php-like query string

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published