PHP: special character as key in array -
my problem use special character & key , seems not work
my array this
$legalforms = array( 'gmbh & co.kg' => array( 'namestosubmit' =>array( 'companyname'=>'required', 'location'=>'required', 'phone'=>null, 'fax'=>null, 'web'=>null, 'registrycourt'=>'required', 'registrynumber'=>'required', 'companynameassociate'=>'required', 'locationassociate'=>'required', 'registrycourtassociate'=>'required', 'registrynumberassociate'=>'requuired', 'ceo'=>'required' ), ) )
and when want use namestosubmit error property of nametosubmit null, if remove special character & out of , works.. how can work & ?
edit:
$("#sendlegalform").click(function () { selection = $('#selection').val(); $.ajax({ type:'get', url:'http://192.168.10.24/php/sig.php?selectedlegalform='+ selection, datatype:'json', success: function (data){ $("#legalform").hide(); $("#fields").show(); var fieldnames =[]; for(property in data.namestosubmit){ fieldnames.push(property); } var fields=[]; for(var i=0; i<data.textfieldheaders.length; i++){ fields.push(data.textfieldheaders[i],'<br>','<input name="',fieldnames[i],'" type="text" ',data.namestosubmit[fieldnames[i]] == "required"?"required":"",'>','<br/>'); } fields.push("<br>", 'pflichtfelder (*)'); $("#fieldsform").prepend(fields.join('')); }, error: function(jqxhr,textstatus,errorthrown){ console.log(jqxhr); console.log(textstatus); console.log(errorthrown); } }); });
and error in line
for(property in data.namestosubmit){
tried md5 , didn´t work , help
change request method post
:
$.ajax({ type:'post', url: 'http://192.168.10.24/php/sig.php', data: {selectedlegalform: selection}, ...
in php:
$data = $_post['selectedlegalform'];
if send string gmbh & co.kg
via get
becomes gmbh%20%26%20co%2ekg
. should problem.
Comments
Post a Comment