PHP array unset by value

if(($key = array_search($del_val, $messages)) !== false) {
    unset($messages[$key]);
}
public function taskWaterList($where,$order,&$page,$countSql,$dataSql){ if(!$order){ $order = 'id asc'; } $sql = $countSql; $count = $this->query($sql); foreach ($count as $key => $value) { $dataCount +=$value['count']; } if(!$where['export']){ $pageSize = C('PAGE_LIMIT'); }else{ unset($where['export']); $pageSize = 1000; } $page = new \Think\Page($dataCount, $pageSize, array('p' =>$page)); // $sql1 = $this->where($where)->buildSql(); $data = $dataSql.'order by '.$order.' limit '.$page->firstRow.', '.$page->listRows.''; $taskWaterList = $this->query($data); foreach ($taskWaterList as $key => &$value) { $value['no'] = $key+1+$page->firstRow; } unset($value); return $taskWaterList; } public function taskWaterStat($sql){ $sql = 'select count(1) as count,t.taskName,t.taskId from ('.$sql.') t group by t.taskId '; $rewardItem = $this->query($sql); foreach ($rewardItem as $key => &$value) { $value['完成数量'] = $value['count']; $value['count'] = number_format($value['count']); $name2[] = $value['taskName']; } unset($value); $name1 = array('完成数量'); $i = 0; foreach ($name1 as $k => $v) { $itemStat[$i]['name'] = $v; $itemStat[$i]['type'] = 'bar'; foreach ($rewardItem as $key => $value) { $itemStat[$i]['data'][] = $value[$v]; } $i++; } $data = array(); $data['list'] = $rewardItem; $starWaterModel = new \Lib\Fishing\StarWaterModel(); if($rewardItem){ $data['columnChart'] = $starWaterModel->getColumnChart($name1,$name2,$itemStat); }else{ $data['columnChart'] = 1; } return $data; }taskWaterStat实现分页
最新发布
03-25
### PHP Magic Functions List and Usage In PHP, magic methods are special methods that get called automatically by PHP in response to certain events or operations. These methods provide powerful ways to handle object behavior dynamically. #### Constructor and Destructor Methods The `__construct()` method initializes an object when instantiated with new keyword. ```php public function __construct() { // Initialization code here } ``` The `__destruct()` method gets invoked at the end of script execution or when unset occurs on objects[^1]. #### Operator Overloading Methods `__get($name)` allows reading data from inaccessible properties. ```php public function __get($name) { return "Reading property '$name'"; } ``` `__set($name, $value)` enables setting values for non-existent or protected/private members. ```php public function __set($name, $value) { echo "Setting '$name' to '$value'\n"; } ``` For checking existence of a member variable use `__isset($name)` ```php public function __isset($name) { return isset($this->data[$name]); } ``` To clear out variables via unset(), implement `__unset($name)` ```php public function __unset($name) { unset($this->data[$name]); } ``` #### Method Call Handling Handle calls to undefined static methods through `__callStatic($method, $args)` ```php public static function __callStatic($method, $args) { // Handle call statically... } ``` Deal with invocations of unimplemented instance methods using `__call($method, $args)` ```php public function __call($method, $args) { // Handle dynamic method invocation... } ``` #### String Representation Conversion Convert object into string representation upon casting to `(string)` ```php public function __toString() { return "Object represented as string."; } ``` #### Sleep/Wakeup Serialization Hooks Prepare serialization process within `__sleep()`. This returns array containing names of all serializable elements. ```php public function __sleep() { return ['property']; } ``` Restore state after deserialization inside `__wakeup()`. ```php public function __wakeup() { // Reconnect resources etc. } ``` #### Debug Information Provider Provide debug information about current object status implementing `__debugInfo()` ```php public function __debugInfo() { return [ 'custom_key' => 'custom_value' ]; } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值