Jump to content

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>';
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.