962 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
EireStudio says

Hey Guys,

I am storing the entire $_POST array in my options panel, but it stores the empty fields too (dynamically generated). How do I filter out the empty value and not include them?

This doesn’t work :(

<?php foreach($_POST['eirepanel_inline_ads_options_name'] as                                         $post_eirepanel_inline_ads_options_name):
if(empty($post_eirepanel_inline_ads_options_name)): 
echo 'empty';
else: 
update_option('eirepanel_inline_ads_options', $_POST);
$eirepanel_inline_ads_options = get_option('eirepanel_inline_ads_options');
endif; 
endforeach;
?>
272 posts The Dominant One
  • Has referred 50+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
wptitans says

if(trim($post_eirepanel_inline_ads_options_name)==""):
echo "empty";


This is how I do it :)

962 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
EireStudio says

Thanks for the reply mate but I am storing the POST array so your solution would not work :(

3256 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+9 more
ParkerAndKent says

Thanks for the reply mate but I am storing the POST array so your solution would not work :(

You should loop though the $_POST array and create a new array with the only values you need… make a print_r($_POST); to see how many things that you don’t need are in it.

27 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
feeleep says

I guess ‘empty’ will not work. Did you try ‘isset’ instead? If not working, comparing it with an empty string ( if( $_POST[ ‘var_name’ ] != ’’ ) ) should work.

147 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
FlexiPress says

@RedHenry,

It is not easy to give you the best direction if we can’t see the full code, we don’t know how you write your form elements…

If you are familiar with debugging, you can try ParkerAndKent’s suggestion, print_r($_POST); will output all arrays that will help you analyze your problem. you can also try to use print_r($_POST[‘eirepanel_inline_ads_options_name’]) and we can see the stored value…

you can also send your full code to me through my Profile page and i would love to check it ;)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by