dongzang7182 2016-12-30 21:44
浏览 39
已采纳

如何为每个循环数组和调用函数?

I have an array that I need to loop through, and for specific keys, I then need to call chopActNum function. The function takes an account number, and turns it into the "xxxxxxxxxx1234" format. I would like to then display this new format rather than the whole account number. My $accountList holds all the information for the accounts. My confusion is in that I currently display all my account information through assignment in Smarty templating. I am horrible at explaining, so perhaps seeing my code will help elucidate my issue.
My function:

public function chopActNum($actNum=0){

    $numPlace=strlen($actNum)-4;
    $repeatX=str_repeat('x',$numPlace);
    $actNumConcat=$repeatX.substr($actNum, -4); 
    return $actNumConcat;

Php:

foreach($achList as $a)
{
$actNum[] = $a['actNum'];
$chopNum=$Ach->chopActNum($actNum);
}

$achList=$Ach->listAch($logged_userid);
$smarty->assign("accountList",$achList);

Tpl Code:

{foreach from=$accountList item=v name=foo} 
<td class="tableData">{$v.actName}</td>
<td class="tableData">{$v.actNum}</td>
<td class="tableData">{$v.bankRoute}</td>
{/foreach}
  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 keil MDK软件进行仿真调试的局限
      • ¥15 关于gateway产生临时文件夹的问题
      • ¥15 Java Broken Pipe以及OOM
      • ¥20 请问有没有RTL8211FS的参考原理图
      • ¥30 esp32的platfromio工程添加文件就会编译失败
      • ¥15 linux下运行VASP报错
      • ¥15 python里面查找赋值,如何可以在剩余未空值的行里面进行进一步的筛选呢?
      • ¥15 电路分析的综合实验有没有会的
      • ¥15 #硬件设计#PNP三级管输出设计问题
      • ¥30 ORACLE的procedure突然需要重新编译是为什么?