duangu4943 2015-07-27 20:06
浏览 45

变量次数静态数+变量

Not 100% sure I can do this.. But I am wondering if it is possible. I want to be able to do something like this ;

    $a = 5
    $b = mt_rand(125,245); 
    $c = $a*1.0$a;

So A = 5 ( for an example, it will be different on different criteria, B is then the random number x 1.0 and the variable..

So this example would be $c = $b*1.05

But as the variable A will look at a specific column in a table it isn't always 5. Am I making this way too complex, is there a more simple way to do this?

I would prefer the table variable to NOT be 1.05 for example.. As it would be easier for me to display just 5

  • 写回答

2条回答 默认 最新

  • douyan5481 2015-07-27 20:13
    关注

    you're on the right track,

    $a = 5;
    $b = mt_rand(125,245); 
    $c = $b*(float)('1.0'.$a);
    

    make the 1.0 portion a string, concatenate the contents of $a and then type juggle it back to a float and it should work how you're expecting.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动