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
https://forums.phpfreaks.com/topic/211151-php-array-with-help-request-p/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.