Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:45:51+00:00 2026-05-28T17:45:51+00:00

Is this code possible? A stupid question but I am having a problem understanding

  • 0

Is this code possible?

A stupid question but I am having a problem understanding this.
Assuming $product_quality[$i] and $saleprice[$i] are already populated with values.
Passing an array to a function without specifying its key.

Please just follow the $product_value[$i] or $player_value

for ($i=0;$i<5;$i++)
{

$product_value[$i]=($product_quality[$i]/$saleprice[$i]); 

}


$trial_x=find_four($product_value);



function find_four($player_value)
{

$trial_x=2;
$h=5;
$slope=1;

  while(abs($h)>0.01){

   $delta_y=total_value($player_value, $trial_x+0.01)-total_value($player_value, $trial_x)
   $slope=100*$delta_y;
   $h=-(total_value($player_value, $trial_x)-4)/$slope;
   $trial_x=$trial_x+$h;
  }

 return ($trial_x);
}


function total_value($player_value, $x)
{

 $total_value=0;

  for ($i=0;$i<5;$i++)
  {

   $total_value+=Cum_Norm($x,$player_value[$i],$sd[$i]);
  }

return($total_value);
}


function Cum_Norm($x, $mean, $sd)
{
echo $x."****1****<br/><hr/>";
echo $mean."Should be empty?***2****<br/><hr/>";
echo $sd."*****3*****<br/><hr/>";
$z=($x-$mean)/$sd;
echo $z."*****4*****<br/><hr/>";

$b1=0.31938;
$b2=-0.35656;
$b3=1.78148;
$b4=-1.82126;
$b5=1.33027;
$c=0.3989423;

if ($z>=0)
{
   $t=1/(1+0.2316419*$z);
   echo $t."*****5*****<br/><hr/>";
   return (1.0 - $c * exp( -$z * $z / 2 ) * $t * ( $t *( $t * ( $t * ( $t * $b5 + $b4 ) + $b3 ) + $b2 ) + $b1 ));  
}

else
{
$t=1/(1-0.2316419*$z); 
echo $t."*****5*****<br/><hr/>";  
return ($c * exp( -$z * $z / 2 ) * $t * ( $t *( $t * ( $t * ( $t * $b5 + $b4 ) + $b3 ) + $b2 ) + $b1 ));  
}
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:45:52+00:00Added an answer on May 28, 2026 at 5:45 pm

    The whole array $product_value is passed as a full array to the function find_four(). However, find_four() does not directly make use of the values in the $product_value array. Instead, the complete array is passed next to the function total_value().

    total_value() receives the whole array (called $player_value in scope of the function find_four()) and performs calculations using all elements of the array. total_value() receives the array and uses its elements inside a for loop.

    It isn’t totally clear from your question what you don’t understand, but it seems to be the part about passing a whole array rather than individual values. An array can be passed to a function, and indeed all the built-in PHP array_*() functions depend on that behavior.

    By default, PHP passes arrays between functions by value rather than by reference, so the function receives a copy of the original array rather than the original. Any modifications the function makes to the array passed in are local modifications only.

    Arrays (like any values) can be passed by reference as in function_call(&$array), so modifications inside function_call() will modify the original array passed to it. Certain built-ins like sort() accept an array reference, therefore acting on the original array passed in without needing to return it and assign it back to a variable.

    $input_array = array(1,2,3,4,5);
    
    // Pass the whole array to a function (by value)
    function showArray($input_array) {
      print_r($input_array);
    }
    
    showArray($input_array);
    Array
    (
        [0] => 1
        [1] => 2
        [2] => 3
        [3] => 4
        [4] => 5
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a weird or stupid question, but I have the following code
This probably sounds like a stupid question, but I'm going to give it a
This might sound like a very stupid question to some of you, but I
Wow, what a stupid question you might say. But is it possible? I have
This may turn out to be an embarrassingly stupid question, but better than potentially
Maybe this is a stupid question but it's bugging me. I have a bi-directional
Sorry if this is a silly and/or stupid question but... Will there ever be,
This may be a stupid question, but I'll feel stupider if I don't ask
This is probably a stupid question but will ask anyway sine I have no
I'm not too good with css so this is probably a stupid question but...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.