Jump to content

[SOLVED] Spaces in array name


loyx

Recommended Posts

I need to use spaces in the name of an array (something along the lines of $_POST[name with spaces in it]) so I can preserve I am trying to make a php mailer for. I read that using braces like this would work:

${'_POST[name with spaces in it]'}

however when I do this it doesn't seem to output anything.

Does anyone know how to do this?

 

Link to comment
https://forums.phpfreaks.com/topic/150811-solved-spaces-in-array-name/
Share on other sites

Thanks, both solutions worked just fine :D.

 

Just one more question. There is a # in the name (something like $_POST[Just Like_# This]) and when I try to use it it spits out the following error

Parse error: syntax error, unexpected T_LNUMBER, expecting ']'

 

This error pops up the moment I include a # in the name. Does anyone know how to get php to cooperate with that symbol?

With that error it seems you're forgetting to enclose the string in quotes.

 

$_POST['Just Like_# This']

 

If that value is empty when you don't expect it to be, have a look at the names of the actual array keys, since certain characters are converted, like wildteen88 pointed out:

 

<?php
echo '<pre>', print_r($_POST, true), '</pre>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.