本文整理汇总了PHP中arr2str函数的典型用法代码示例。如果您正苦于以下问题:PHP arr2str函数的具体用法?PHP arr2str怎么用?PHP arr2str使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arr2str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProducts
/**
* 该方法的返回值为一下格式
* $result => {
* ' headers'=> //提供列表的头
* ' rows'=> //列表的内容(当前商品的属性的自由组合)
* }
*
*
*当前商品的属性值的值自由组合的sql
* select concat(t0.id,'#',t1.id) as goods_attribute_ids,t0.value as value0,t1.value as value1 from
(select id,value from goods_attribute where goods_id = 16 and attribute_id =2) as t0,
(select id,value from goods_attribute where goods_id = 16 and attribute_id = 6) as t1
order by t0.id,t1.id
*
*/
public function getProducts($goods_id)
{
//>>1.准备headers的数据(当前商品的多值属性)
$headers = $this->getMultValueAttribute($goods_id);
//>>2.准备rows的数据
//>>2.1 拼装自由组合的sql
$sql = "select concat(";
$goods_attribute_ids = array();
//存放id
$values = array();
//存放值
$selects = array();
foreach ($headers as $k => $header) {
$goods_attribute_ids[] = "t{$k}.id";
$values[] = "t{$k}.value as value{$k}";
$selects[] = "(select id,value from goods_attribute where goods_id = {$goods_id} and attribute_id ={$header['id']}) as t{$k}";
}
$sql .= arr2str($goods_attribute_ids, ",'#',") . ' ) as goods_attribute_ids,';
$sql .= arr2str($values, ',') . ' from ';
$sql .= arr2str($selects, ',') . ' order by ';
$sql .= arr2str($goods_attribute_ids, ',');
//>>2.2 再执行查询
$rows = $this->query($sql);
foreach ($rows as &$row) {
//>>这两步保证下的在前面
$goods_attribute_ids = str2arr($row['goods_attribute_ids'], '#');
sort($goods_attribute_ids);
$row['goods_attribute_ids'] = arr2str($goods_attribute_ids, '#');
}
//>>2.3.准备当前商品对应的产品
$products = $this->where(array('goods_id' => $goods_id))->select();
$goods_attribute_ids = array_column($products, 'goods_attribute_ids');
$products = array_combine($goods_attribute_ids, $products);
return array('headers' => $headers, 'rows' => $rows, 'products' => $products);
}
示例2: getMultAttribute
/**
* 得到商品的多值属性,产品列表数据
* @param $goods_id
* @return array
*/
public function getMultAttribute($goods_id)
{
//查询当前商品的多值的name
$sql = "select DISTINCT a.name,ga.attribute_id from goods_attribute as ga join attribute as a on ga.attribute_id=a.id where ga.goods_id={$goods_id} and a.input_type=2 and a.attribute_type=2";
$head = $this->query($sql);
//查询当前商品的多值笛卡尔积组合
$rows = '';
if ($head) {
//拼凑sql
$table = '';
$field1 = '';
$field2 = '';
foreach ($head as $k => $v) {
$field1 .= "t{$k}.value as value{$k},";
$field2 .= "t{$k}.id,'#',";
$table .= "(select * from goods_attribute where goods_id={$goods_id} and attribute_id={$v['attribute_id']}) as t{$k},";
}
$sql = 'select concat(' . trim($field2, ',\'#\',') . ') as attribute_ids,' . trim($field1, ',') . ' from ' . trim($table, ',');
$rows = $this->query($sql);
//将结果中attribute_ids排序
foreach ($rows as &$row) {
$temp = str2arr($row['attribute_ids'], '#');
sort($temp);
//排序
$row['attribute_ids'] = arr2str($temp, '#');
}
unset($row);
}
return array('head' => $head, 'rows' => $rows);
}
示例3: sortAction
public function sortAction()
{
$data = post("data", "txt");
$id = post("id", "int");
$plugs = arr2str($data, ",");
$res = db()->table('hook')->upDate(array('plugs' => $plugs), array('id' => $id))->done();
if ($res) {
return JsonObject(array("msg" => "保存成功"));
}
}
示例4: array
/**
* 重构请求参数
* 将xxx数据重构为yyy数据
*
* array(4) {
["goods_attribute_ids"] => array(2) {
["颜色"] => string(1) "8"
["尺码"] => string(2) "10"
}
["goods_attribute_strs"] => array(2) {
["颜色"] => string(6) "红色"
["尺码"] => string(1) "M"
}
["amount"] => string(1) "1"
["goods_id"] => string(2) "16"
}
*
*
* array(4) {
["goods_attribute_ids"] => string(4) "8#10"
["goods_attribute_strs"] => string(26) "颜色:红色<br/>尺码:M"
["amount"] => string(1) "1"
["goods_id"] => string(2) "16"
}
* @param $requestData
*/
private function rebuildRequestData(&$requestData)
{
if (!empty($requestData['goods_attribute_ids'])) {
//说明当前购买的商品是 多库存多价格
//组合商品属性的id
$goods_attribute_ids = array_values($requestData['goods_attribute_ids']);
sort($goods_attribute_ids);
$requestData['goods_attribute_ids'] = arr2str($goods_attribute_ids, '#');
//组合商品属性的值
$goods_attribute_strs = array();
foreach ($requestData['goods_attribute_strs'] as $k => $v) {
$goods_attribute_strs[] = $k . ':' . $v;
}
$goods_attribute_strs = arr2str($goods_attribute_strs, '<br/>');
$requestData['goods_attribute_strs'] = $goods_attribute_strs;
}
}
示例5: update
/**
* 新增或更新一个文档
* @param array $data 手动传入的数据
* @return boolean fasle 失败 , int 成功 返回完整的数据
* @author huajie <banhuajie@163.com>
*/
public function update($data = null)
{
/* 获取数据对象 */
$data = $this->token(false)->create($data);
$data['file_id'] = think_decrypt($data['file_id']);
//推荐位
if (is_array($data['position'])) {
$data['position'] = arr2str($data['position']);
}
//组图
if (is_array($data['pics_id'])) {
$data['pics_id'] = arr2str($data['pics_id']);
}
//附件
$data['file_id'] = think_decrypt($data['file_id']);
if (empty($data)) {
return false;
}
/* 添加或新增基础内容 */
if (empty($data['id'])) {
//新增数据
$id = $this->data($data)->add();
//添加基础内容
if (!$id) {
$this->error = '新增基础内容出错!';
return false;
}
} else {
//更新数据
$status = $this->data($data)->save();
//更新基础内容
if (false === $status) {
$this->error = '更新基础内容出错!';
return false;
}
}
//内容添加或更新完成
return $data;
}
示例6: OAuthWeixin
function OAuthWeixin($callback)
{
$isWeixinBrowser = isWeixinBrowser();
$info = get_mpid_appinfo();
trace('wechat:OAuthWeixin' . $info['id'], '微信', 'DEBUG', true);
if (!$isWeixinBrowser || $info['type'] != 2 || empty($info['appid'])) {
redirect($callback . '&openid=-1');
}
$param['appid'] = $info['appid'];
if (!isset($_GET['getOpenId'])) {
$param['redirect_uri'] = $callback . '&getOpenId=1';
$param['response_type'] = 'code';
$param['scope'] = 'snsapi_base';
$param['state'] = 123;
$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query($param) . '#wechat_redirect';
trace('OAuthWeixin111' . $url, '微信', 'DEBUG', true);
redirect($url);
} elseif ($_GET['state']) {
$param['secret'] = $info['secret'];
$param['code'] = I('code');
$param['grant_type'] = 'authorization_code';
$url = 'https://api.weixin.qq.com/sns/oauth2/access_token?' . http_build_query($param);
$content = file_get_contents($url);
$content = json_decode($content, true);
trace('wechat:OAuthWeixin222' . arr2str($param), '微信', 'DEBUG', true);
trace('wechat:OAuthWeixin333' . $content['openid'], '微信', 'DEBUG', true);
redirect($callback . '&openid=' . $content['openid']);
}
}
示例7: AjaxExistMeeingRoom
public function AjaxExistMeeingRoom()
{
$MeetingreservID = $_REQUEST["id"];
$MeetingID = $_REQUEST["meetingid"];
$StartDate = $_REQUEST["startdate"];
$StartTime = $_REQUEST["starttime"];
$EndTime = $_REQUEST["endtime"];
$Devs = $_REQUEST["devs"];
//选择的设备ID
/*
P_MeetingID integer,
P_StartDate date,
P_StartTime time,
P_EndTime time
*/
if (empty($MeetingreservID)) {
$MeetingreservID = 0;
}
//$strSql=format("Call UP_GetMeetingDevicesByAdd ('{0}','{1}','{2}','{3}')",$StartDate,$StartTime,$EndTime,'12');
$strSql = format("Call UP_ExistMeeingRoom('{0}','{1}','{2}','{3}','{4}')", $MeetingreservID, $MeetingID, $StartDate, $StartTime, $EndTime);
//echo $strSql;
$Meetslist = M('')->query($strSql);
$result = array();
if (count($Meetslist) > 0) {
$result['error'] = "会议室已被占用";
//$result['message'] = "会议室已被占用";
exit(json_encode($result));
} else {
$pDevs = arr2str($Devs, ',');
$strSql = format("Call UP_ExistMeeingDevices('{0}','{1}','{2}','{3}','{4}')", $MeetingreservID, $pDevs, $StartDate, $StartTime, $EndTime);
$DevsList = M('')->query($strSql);
//var_dump($DevsList) ;
if (count($DevsList) > 0) {
$arrDeviceNames = array();
foreach ($DevsList as $key => $value) {
array_push($arrDeviceNames, $value["DeviceName"]);
// var_dump($value["DeviceName"]);
}
// var_dump($arrDeviceNames );
$result['error'] = format("设备已被占用[{0}]", arr2str($arrDeviceNames, ','));
//$result['message'] = "设备已被占用";
exit(json_encode($result));
}
$result['ok'] = '';
//$result['message'] = "";
exit(json_encode($result));
}
}
示例8: responseMsg
//wxb03abb1444f7308f
//4ee5b123dc62e93e3778f7900062c823
//https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8888888888888888&redirect_uri=http://mascot.duapp.com/oauth2.php&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect
public function responseMsg()
{
//get post data, May be due to the different environments
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
//extract post data
if (!empty($postStr)) {
/* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,
the best way is to check the validity of xml by yourself */
libxml_disable_entity_loader(true);
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$keyword = trim($postObj->Content);
$kres = M('wxregular')->where("`wxkeyword`='" . $keyword . "'")->find();
if ($kres) {
// if($kres['type'] == 'text') {
$content = $kres['wxcontent'];
$result = $this->transmitText($postObj, $content);
echo $result;
// } else if($kres['type'] == 'news') {
//
// $content = array();
//
// $content[] = array("Title"=>$kres['title'], "Description"=>$kres['description'], "PicUrl"=>"http://laonian.hzasion.com".get_cover($kres['image'], 'path'), "Url" =>$kres['url']);
//
// $result = $this->transmitNews($postObj, $content);
//
// echo $result;
//
//
//
// }
} else {
if ($keyword == '') {
$content = '请回复 “爱的老人节” 参与投票活动!' . arr2str($kres);
$result = $this->transmitText($postObj, $content);
echo $result;
} else {
$content = '无效关键字' . arr2str($kres);
$result = $this->transmitText($postObj, $content);
echo $result;
}
}
} else {
示例9: array
$groupUser = $new['group']->findAll('group_user', array('groupid' => $groupid), 'addtime desc', null, 8);
if (is_array($groupUser)) {
foreach ($groupUser as $item) {
$strUser = aac('user')->getOneUser($item['userid']);
if ($strUser) {
$arrGroupUser[] = $strUser;
} else {
$new['group']->delete('group_user', array('userid' => $item['userid'], 'groupid' => $groupid));
}
}
}
//标签
$strGroup['tags'] = aac('tag')->getObjTagByObjid('group', 'groupid', $strGroup['groupid']);
if ($page > 1) {
$title = $strGroup['groupname'] . ' - 第' . $page . '页';
}
//把标签作为关键词
if ($strGroup['tags']) {
foreach ($strGroup['tags'] as $key => $item) {
$arrTag[] = $item['tagname'];
}
$sitekey = $strGroup['groupname'] . ',' . arr2str($arrTag);
} else {
$sitekey = $strGroup['groupname'];
}
$sitedesc = tsCutContent($strGroup['groupdesc'], 50);
if ($TS_CF['mobile']) {
$sitemb = tsUrl('moblie', 'group', array('ts' => 'show', 'groupid' => $strGroup['groupid']));
}
include template("show");
}
示例10: defined
<?php
defined('IN_TS') or die('Access Denied.');
$arrGroupUser = $new['my']->findAll('group_user', array('userid' => $strUser['userid']));
foreach ($arrGroupUser as $key => $item) {
$arrGroupId[] = $item['groupid'];
}
$strGroupId = arr2str($arrGroupId);
if ($strGroupId) {
$arrTopic = $new['my']->findAll('group_topic', "`groupid` in ({$strGroupId})", 'addtime desc', null, 30);
foreach ($arrTopic as $key => $item) {
$arrTopic[$key]['user'] = aac('user')->getOneUser($item['userid']);
$arrTopic[$key]['group'] = aac('group')->getOneGroup($item['groupid']);
}
}
include template("index");
示例11: applylead
public function applylead()
{
$id = is_login();
if (!$id) {
$this->error('您还没有登录,请先登录。', U('User/login'));
return;
}
if (IS_POST) {
$focus = $_POST['focus'];
if (empty($focus)) {
$this->error('请选择您感兴趣的领投领域。');
}
if (empty($_POST['resume'])) {
$this->error('请完善您的个人简介。');
}
//领投资格
$ret = M('user_auth')->where(array('uid' => $id, 'auth_id' => 1, 'status' => 9))->find();
if (!$ret) {
$this->error('您还没有进行实名认证,不能申请领投人。请先进行实名认证。', U('User/savecenter'));
}
$data = array('resume' => $_POST['resume'], 'focus' => arr2str($focus), 'id' => $id);
M('UsersDetail')->save($data);
//保存用户类别
$auth_id = 3;
$ret = M('user_auth')->where(array('uid' => $id, 'auth_id' => $auth_id))->find();
if (!$ret) {
$data = array('uid' => $id, 'auth_id' => $auth_id);
M('user_auth')->add($data);
} else {
if ($ret['status'] != 9) {
$ret['status'] = 0;
M('user_auth')->save($ret);
}
}
$this->success('领投信息提交成功!');
} else {
$userdetail = M('UsersDetail')->find($id);
$userauth = M('user_auth')->where(array('uid' => $id, 'auth_id' => 3))->find();
if ($userauth['status'] == '1') {
$describe = M('Users')->field('investor_content')->find($id);
$this->describe = $describe['investor_content'];
}
$this->industry = get_code('industry');
$this->userdetail = $userdetail;
$this->userauth = $userauth;
$this->display('applylead');
}
}
示例12: delcate
public function delcate($cid = null)
{
$this->data['title'] = "删除栏目";
$this->load->view('mzsj/com_header', $this->data);
if (isset($_POST['dosubmit'])) {
$cids = $this->input->post('cids[]');
foreach ($cids as $c) {
$res = $this->delchildcat($c);
if ($res !== true) {
$this->msg('栏目' . $res . '下有文章,请先删除文章!', 'mzsj/content/cate');
return;
} else {
continue;
}
}
// 记录用户行为
$cids = arr2str($cids);
$this->addlog("catid={$cids}");
} else {
if ($cid == NULL || (int) $cid <= 0) {
$this->msg('Parameter Error!', 'mzsj/content/cate');
} else {
$res = $this->delchildcat((int) $cid);
if ($res === true) {
// 记录用户行为
$this->addlog("catid={$cid}");
} else {
$this->msg('栏目' . $res . '下有文章,请先删除文章!', 'mzsj/content/cate');
return;
}
}
}
$this->updatecache->catecache();
$this->msg('Delete Success!', 'mzsj/content/cate');
$this->load->view('mzsj/com_footer');
}
示例13: get_room_name
function get_room_name($room_id)
{
if ($room_id) {
$room_name = arr2str(M('Room')->where('id=' . $room_id)->field('name')->find());
if ($room_name) {
return $room_name;
}
}
}
示例14: tsUrl
$strTopic['content'] = @preg_replace("/\\[@(.*)\\:(.*)]/U", "<a href='" . tsUrl('user', 'space', array('id' => '$2')) . " ' rel=\"face\" uid=\"\$2\"'>@\$1</a>", $strTopic['content']);
// 最新帖子
$newTopic = $new['group']->findAll('group_topic', array('isaudit' => '0'), 'addtime desc', null, 10);
foreach ($newTopic as $key => $item) {
$newTopic[$key]['title'] = tsTitle($item['title']);
$newTopic[$key]['content'] = tsDecode($item['content']);
}
// 帖子标签
$strTopic['tags'] = aac('tag')->getObjTagByObjid('topic', 'topicid', $topicid);
$strTopic['user'] = aac('user')->getOneUser($strTopic['userid']);
//把标签作为关键词
if ($strTopic['tags']) {
foreach ($strTopic['tags'] as $key => $item) {
$arrTag[] = $item['tagname'];
}
$sitekey = arr2str($arrTag);
} else {
$sitekey = $strTopic['title'];
}
//标题
$title = $strTopic['title'];
// 评论列表开始
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$url = tsUrl('group', 'topic', array('id' => $topicid, 'page' => ''));
$lstart = $page * 15 - 15;
$arrComment = $new['group']->findAll('group_topic_comment', array('topicid' => $topicid), 'addtime asc', null, $lstart . ',15');
foreach ($arrComment as $key => $item) {
$arrTopicComment[] = $item;
$arrTopicComment[$key]['l'] = ($page - 1) * 15 + $key + 1;
$arrTopicComment[$key]['user'] = aac('user')->getOneUser($item['userid']);
$arrTopicComment[$key]['content'] = @preg_replace("/\\[@(.*)\\:(.*)]/U", "<a href='" . tsUrl('user', 'space', array('id' => '$2')) . " ' rel=\"face\" uid=\"\$2\"'>@\$1</a>", tsDecode($item['content']));
示例15: addPlugs
/**
* 添加单个钩子里对应的插件数据
* @param $hook_name
* @param $plug_name
* @return bool|mixed
*/
public function addPlugs($hook_name, $plug_name)
{
$o_plugs = db()->table("hook")->getRow(array("name" => $hook_name))->fields('plugs')->done();
if ($o_plugs) {
$plugs = array_unique(array_merge($o_plugs, $plug_name));
} else {
return true;
}
$flag = db()->table("hook")->upDate(array('plugs' => arr2str($plugs)), array('name' => $hook_name))->done();
if (false === $flag) {
db()->table("hook")->upDate(array('plugs' => arr2str($o_plugs)), array('name' => $hook_name))->done();
}
return $flag;
}