urlencode-for-php

encode object/array to php-like query string

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
urlencode-for-php
101.0.45 years ago7 years agoMinified + gzip package size for urlencode-for-php in KB

Readme

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