Code: Select all
echo "<input type=checkbox name=b[$a] value=1>view,";
Moderator: General Moderators
Code: Select all
echo "<input type=checkbox name=b[$a] value=1>view,";
Use single quotes, liketomindo wrote:I m trying to submit array b, it works fine if $a is string without space but string with space like "my name". That is really weirdCode: Select all
echo "<input type=checkbox name=b[$a] value=1>view,";
Code: Select all
echo "<input type=\"checkbox\" name=\"b['".$a."']\" value=\"1\">view,";
Because if there is no quotes PHP can't "guess" where does string ends. Space separates language tokens.tomindo wrote:thanks man
why did that happen, btw?
Actually, the problem occurs in HTML. Whitespace separates element attributes in HTML. Without quotes, the second word becomes a new attribute.Technical wrote:PHP can't "guess" where does string ends.
Code: Select all
$a = 'box checked';
echo "<input type=checkbox name=b[$a] value=1>view,";Code: Select all
<input type=checkbox name=b[box checked] value=1>view,Code: Select all
<input type="checkbox" name="b[box" checked]="" value="1">