770 snippets from 1550 members, and growing!
|
login
|
join
about
bytebin
members
tags
snippets
join
Snippets
Submit a Snippet
Search Snippets
New Snippets
Top Snippets
Top Tags
PHP
(136)
JavaScript
(123)
Java
(66)
VBSCRIPT
(58)
String
(44)
CSS
(31)
CSharp
(28)
File
(28)
HTML
(27)
C
(24)
mysql
(24)
VB.NET
(24)
python
(24)
CPlusPlus
(23)
groovy
(23)
New Snippets
Very lightweight ...
AutoComplete plug...
AutoComplete plug...
Connection Java -...
View PostgreSql
Store Procedure
Pygame - Simple p...
Python - Anagram ...
Python - Anagram ...
Converter to bina...
Venture Capital Jobs
New Members
me
jamesmcm
Can
Kelmi
ysg
dannymo2
chorny
wallie
Hackdemian
impomatic
Top Members
dannyboy
sundaramkumar
mattrmiller
Pio
i_kenneth
ASmith
ctiggerf
sehrgut
bertheymans
SCoon
Home
/
Snippets
/
Convert a name=value pairs string into array
/
Comments
Convert a name=value pairs string into array
Snippet Menu
Revisions
Comments
Related Snippets
Add to Favorites
Email Snippet
Download Snippet
Print Snippet
Blog Snippet
snippet
|
revisions
|
comments
|
related
|
Add to Favorites
|
email
download
|
print
|
blog it
New Comment
...
Fri. Jul. 21st, 2006 12:48 AM
hello2usir
http://us2.php.net/manual/en/function.parse-str.php
And if you must use commas just str_replace it with &.
Reply
Beat me
Tue. Aug. 8th, 2006 8:29 PM
schmalls
I was going to post about parse_str, but you already had done so. However, the posted function does have the ability to work with name-value pairs that have spaces around the deliminator, and parse_str doesn't seem to.
Reply
Example of input and output
Thu. Feb. 16th, 2006 7:00 AM
nev3rm0re
Please provide an example of input string and output array.
I would also rewrite your function, adding a second optional parameter - delimiter.
PHP
function
pairstr2Arr
(
$string
,
$delimiter
=
','
)
{
$pairs
=
explode
(
$delimiter
,
$string
)
;
...
}
Reply
New Comment
And if you must use commas just str_replace it with &.
I would also rewrite your function, adding a second optional parameter - delimiter.
function pairstr2Arr($string, $delimiter = ',') {
$pairs = explode($delimiter, $string);
...
}