Jump to content

Recommended Posts

 

 

I have the following when I print out $_POST

 

Array ( [submit] => Submit [se1] => qqqq [se2] => wwwww [se3] => [se4] => [se5] => [se6] => [se7] => [sid] => 82ea244a6fd9125be1a200a3d211d370 [lang] => en [station] => [dept] => [dept_nr] => 25 [pn] => 45272 [batch_nr] => 955071 [edit] => 0 [target] => admin [subtarget] => baclabor [tracker] => 32 [noresize] => [user_origin] => lab [status] => pending [mode] => save [formtitle] => Bacteriological Laboratory [entry_date] => )

 

I would like to filter it out and leave only the one's with values e.g. remove [se4] =>

In that case I'd probably use

 

foreach ($_POST as $key => $value)
{
   if (empty($v))
   {
      continue;
   }
   else
   {
      $posted[$key] = $v
   }
}

 

You should have an array ($posted) that just contains the relevant fields.

 

Regards

Huggie

 

 

I have the following when I print out $_POST

 

Array ( [submit] => Submit [se1] => qqqq [se2] => wwwww [se3] => [se4] => [se5] => [se6] => [se7] => [sid] => 82ea244a6fd9125be1a200a3d211d370 [lang] => en [station] => [dept] => [dept_nr] => 25 [pn] => 45272 [batch_nr] => 955071 [edit] => 0 [target] => admin [subtarget] => baclabor [tracker] => 32 [noresize] => [user_origin] => lab [status] => pending [mode] => save [formtitle] => Bacteriological Laboratory [entry_date] => )

 

I would like to filter it out and leave only the one's with values e.g. remove [se4] => (This is done! Thanks for the code guys)

 

Then have a string like this

 
sel=jjjjjjj&=se2=hhhhhhhhhh&

 

showing the index and value combination only for those indexes that start with 'se' e.g.[se1]

if its blank like this [se4] => don't display it. it should be displayed only when its this way [se4] => www

the array element has a value.

 

 

The solution :

 

<?php

$values = array();

if(count($_POST)){

  foreach($_POST AS $k=>$v){

      if(isset($v) && strlen(trim($v)){

        $values[$k] = trim($v);

          if (k{o} == 's')

                    {

                if (k{1} == 'e')

                      {

                          $res = $res. $k .'='.$v.'&=';

                          }

                              }

 

       

      }

 

 

Jesirose, Thanks a Million Times !!!!!!!!!!!!!!!!!!

 

 

  }

  print_r($values);

}else{

  print 'no posted';

}

?>

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.