可按Ctrl+D收藏 蚂蚁资源网

蚂蚁资源网

php源码(php资源网源码)

  • 全部评论(3)
  • 招财猫科技
  • 根据你的描述,好像是显示产品的一个格式,$a, $id,$num,$money分别是对应各个产品的属性,$count则是计算所有产品的总价值,那么php代码可以这样写:<?php $a = explode('|', '610|629');$id = explode('|', '3171|2486');$num = explode('|', '8|5');$money = explode('|', '1|1');$count = 0;$totalNum = count($a);echo count($a) . "<br>";$str = "{";for ($i = 0; $i < $totalNum; $i++) {/*$str .= '\"';$str .= $a[$i];$str .= '\":{\"id\":';$str .= $id[$i];$str .= ',';$str .= '\"num\":';$str .= $num[$i];$str .= ',\"money\":';$str .= $money[$i];$str .= '},';*/$str .= sprintf('\"%d\":{\"id\":%d,\"num\":%d,\"money\":%d},', $a[$i], $id[$i], $num[$i], $money[$i]);$count += ($num[$i] * $money[$i]);}$str .= '\"Count\":';$str .= $count;$str .= '}';echo $str;
  • 2021-02-11 12:22:22
  • 551108330
  • $_env 是环境变量,通过环境方式传递给当前脚本的变量的数组。$_ENV['defaultapp'] = array('portal.php' =&gt; 'portal', 'forum.php' =&gt; 'forum', 'group.php' =&gt; 'group', 'home.php' =&gt; 'home');是赋值 , 你可以用 var_dump($_env['defaultapp']) 看赋值结果。--------------------------------------------------------------------$_ENV['hostarr'] = explode('.', $_SERVER['HTTP_HOST']);环境变量 用.分隔 主域名(你可以 echo $_server['HTTP_HOST']里面有什么)----------------------------------------------------------------$url = $domainroot.'forum.php?mod=group&amp;fid='.$domain['id'].'&amp;page=1';构造一个URL 直白点 结果就是: www.some.com/forum.php?mod=1&amp;fid=1&amp;page=1----------------------------------------$url = empty($_ENV['domain']['app']['default']) ? (!empty($_ENV['domain']['defaultindex']) ? $_ENV['domain']['defaultindex'] : 'forum.php') : 'http://'.$_ENV['domain']['app']['default'];结构简化 $url = $a ? (!$b? $c : $d) :$e; 2个3元运算嵌套, 至于看起来复杂的变量都是多维数组的值
  • 2021-02-11 12:22:22
  • 亚亚
  • 一段简单的PHP代码,经运行检测,代码没有问题:1 = 1 2 = 3 3 = 6 4 = 10 5 = 15 6 = 21 7 = 28 8 = 36 9 = 45 10 = 55 11 = 66 12 = 78 13 = 91 14 = 105 15 = 120 16 = 136 17 = 153 18 = 171 19 = 190 20 = 210 21 = 231 22 = 253 23 = 276 24 = 300 25 = 325 26 = 351 27 = 378 28 = 406 29 = 435 30 = 465 31 = 496 32 = 528 33 = 561 34 = 595 35 = 630 36 = 666 37 = 703 38 = 741 39 = 780 40 = 820 41 = 861 42 = 903 43 = 946 44 = 990 45 = 1035 46 = 1081 47 = 1128 48 = 1176 49 = 1225 50 = 1275
  • 2021-02-11 12:22:22
  • 商品推荐