Ask a question about the parse_str function. the parse_str function is very useful. you can convert a string to an array with an index. However, if the index value contains A. sign, it will automatically convert it to an underscore. For example:
$ Key = "modern educational technology ";
$ Postd [1] = "course. title = ";
$ Postdd = $ postd [1]. $ key;
Parse_str ($ postdd, $ fields );
Print_r ($ fields );
How can we prevent the parse_str function from converting the DOT to an underscore.
Reply to discussion (solution)
Parse_str works according to the HTTP protocol.
The. (dot) in the key name is replaced by _ (underline), which is an http protocol convention to prevent ambiguity.
If you want to convert them as they are, you have to write your own code.
$s = 'a.1=2&b.2=3';$p = '/&(?!amp;)/';foreach(preg_split($p, $s) as $v) { $t = explode('=', $v); $r[$t[0]] = $t[1];}print_r($r);
Array( [a.1] => 2 [b.2] => 3)
Method1 = 1 & keyzy = name & keyword = Modern Educational Technology
The above string is parsed and becomes
Array ([method1] => 1)
Yes?
$ S = 'method1 = 1 & keyzy = name & keyword = '; $ p = '/&(?! Amp;)/'; foreach (preg_split ($ p, $ s) as $ v) {$ t = explode (' = ', $ v ); $ r [$ t [0] = $ t [1];} print_r ($ r );
Array ([method1] => 1 [keyzy] => name [keyword] => Modern Educational Technology)