Jump to content

Recommended Posts

obviously that know that i can do

 

$var1 = $form_data_array["ensino"];
function livre($var1) {

}

 

 

i serialize an array and now i need to get the values, basically i want to reduce some lines of code, because i have much variables from serialize.

 

so, the correct syntax is:

 

function livre($form_data_array) {
$form_data_array["ensino"];

}

 

 

correct?

Link to comment
https://forums.phpfreaks.com/topic/238204-array-in-function/#findComment-1224085
Share on other sites

Are you trying to define the function, or call it? If you're defining it, just use a standard variable name for the argument. Use the array element when you call the function.

 

$array = range( 1, 25 );

function check_array($input) {
     if( is_array($input) ) {
          return "Array";
     } else {
          return "Not array";
     }
}

echo check_array( $array );
echo '<br>';
echo check_array( $array[5] );

Link to comment
https://forums.phpfreaks.com/topic/238204-array-in-function/#findComment-1224097
Share on other sites

$form_data_array = array();
$form_data_array = $_POST['myformdata']; 
echo $form_data_array["age"]; //display age correctly 

function check($form_data_array) { 
if (empty($form_data_array["age"])){
echo ("empty");
}
else 
echo ("not empty");

}

 

I need to check if the $form_data_array["age"]; is empty or no

Link to comment
https://forums.phpfreaks.com/topic/238204-array-in-function/#findComment-1224102
Share on other sites

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.