Jump to content

php array * with % (help request :p)


lasse48

Recommended Posts

hello guys , can you guys see any errors in this code`?

i cant seem to find it  :-\

 


<?php

$units_stats_1 = array(40, 35, 50);
$units_stats_2 = array($units_stats_1[0] * 50%, $units_stats_1[1] * 100%, $units_stats_1[2] * 100%);

echo $units_stats_2;


?>



 

i allso tryed to do :


echo $units_stats_2[0];

 

 

thanks  ;)

 

Link to comment
Share on other sites

i assume you mean this,

<?php

$units_stats_1 = array(40, 35, 50);
$units_stats_2 = array( $units_stats_1[0] * (1+(50/100)), $units_stats_1[1] * (1+(100/100)), $units_stats_1[2] * (1+(100/100)));

echo $units_stats_2[0]."<BR />\n";
echo $units_stats_2[1]."<BR />\n";
echo $units_stats_2[2]."<BR />\n";
?>

remove the 1+ if you do mean (40 x 50%) that = 20 and the 35 and 50 would remain unchanged

Link to comment
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.