php - Is it possible to get empty array value via $_GET? -
is possible empty array(array 0 items) value via $_get
?
is possible direct value setting?
count($_get['param'])==0
you need empty value url = myform.php?param=¶m2=
in form let value blank:
<input type='text' name='param' value ='' />
for empty array:
url: myform.php?param[]=¶m2[some_key]=
in form: <input type='text' name='param[]' value ='' />
from ajax: (i remember anti-intuitive , hard search for):
ajax{ ... data: {'params[]':'','params2[some_key]':''} }
workaround: edit back-end , if there no data params
or not array (null, empty whatever ..) assign empty string it:
$param = (isset($_get['param']) && is_array($_get['param']))? $_get['param'] : array();
update:
did few tests , seems there no way put "nothing" in request ussing form or ajax.
0
, ''
, null
valid values $_get
empty array not created. answer question, not possible empty array value front-end.
there few options edit $_get manually in back-end:
<?php if(!isset($_get['param']) || !$_get['param']){ //not set or (null,0,"") $_get['param'] = array(); } if(count($_get['param'])==0){...}; // 0 if no 'param' provided.
Comments
Post a Comment