Unset Designer from variable - php

I am displaying product Id, product name , designer, but i need to hide "designer".
so i am trying to unset designer from variable $orderitems, i am trying below code, but still Designer column displaying
i am fetching product id , name , Designer from this code : ->addAttributeToSelect('dproduct_id') & trying this code to unset : unset($orderitems['designer_id'])
function getDesignerCollection()
{
$user_home = new USER();
$stmts = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmts->execute(array(
":uid" => $_SESSION['userSession']
));
$rows = $stmts->fetch(PDO::FETCH_ASSOC);
$accountType = $rows['type'];
if ($accountType == "admin")
{
$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
'nin' => '0'
));
}
else
{
$order = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('designer_id', array(
'like' => '%' . $_SESSION['userSession'] . '%'
))
->addAttributeToSelect('dproduct_id')
->addAttributeToSelect('state');
//unset($orderitems['designer_id']);
}
$i = 0;
foreach($order as $orderData)
{
$orderitems = $orderData['dproduct_id'];
$orderitemsarray = explode(",", $orderitems);
$k = 0;
$oDate = new DateTime($orderData['created_at']);
$sDate = $oDate->format("Y-m-d");
while ($k < count($orderitemsarray))
{
if ($orderitemsarray[$k] != '0')
{
$stmtorders = $user_home->runQuery("SELECT * FROM order_details WHERE designerorder_id=:designerorder_id");
$stmtorders->execute(array(
":designerorder_id" => $orderData['entity_id']
));
$roworders = $stmtorders->fetch(PDO::FETCH_ASSOC);
$productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
$designerName = getDesignerName($productdetail->getDesignerID()) . " -(" . $productdetail->getDesignerID() . ")";
$responce[] = array(
$orderData->getIncrementId() ,
$orderData->getIncrementId() ,
$orderitemsarray[$k],
$productdetail->getName() ,
$designerName,
$orderData['status'],
$orderData['grand_total'],
$orderData['customer_email'],
$commission,
$dorderStatus,
$sDate
);
}
$k++;
$i++;
}
}
echo json_encode($responce);
unset($orderitems['designer_id']);
}
Note : I really tried lot before posting here, i am new to php.

Related

CSGO Steam API ~ How to fetch both tradeable and non-tradeable items into array

My code is here:
case 'get_inv':
if(!$user) exit(json_encode(array('success'=>false, 'error'=>'You must login to access the deposit.')));
if((file_exists('cache/'.$user['steamid'].'.txt')) && (!isset($_GET['nocache']))) {
$array = file_get_contents('cache/'.$user['steamid'].'.txt');
$array = unserialize($array);
$array['fromcache'] = true;
if(isset($_COOKIE['tid'])) {
$sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
if($sql->rowCount() != 0) {
$row = $sql->fetch();
$array['code'] = $row['code'];
$array['amount'] = $row['summa'];
$array['tid'] = $row['id'];
$array['bot'] = "Bot #".$row['bot_id'];
} else {
setcookie("tid", "", time() - 3600, '/');
}
}
exit(json_encode($array));
}
$prices = file_get_contents('prices.txt');
$prices = json_decode($prices, true);
$inv = file_get_contents('https://steamcommunity.com/profiles/'.$user['steamid'].'/inventory/json/730/2/');
$inv = json_decode($inv, true);
if($inv['success'] != 1) {
exit(json_encode(array('error'=>'Your profile is private. Please set your inventory to public and try again.')));
}
$items = array();
foreach ($inv['rgInventory'] as $key => $value) {
$id = $value['classid'].'_'.$value['instanceid'];
$trade = $inv['rgDescriptions'][$id]['tradable'];
if(!$trade) continue;
$name = $inv['rgDescriptions'][$id]['market_hash_name'];
$price = $prices['response']['items'][$name]['value']*0.9;
$img = 'http://steamcommunity-a.akamaihd.net/economy/image/'.$inv['rgDescriptions'][$id]['icon_url'];
if((preg_match('/(Souvenir)/', $name)) || ($price < $min)) {
$price = 0;
$reject = 'Junk';
} else {
$reject = 'unknown item';
}
$items[] = array(
'assetid' => $value['id'],
'bt_price' => "0.00",
'img' => $img,
'name' => $name,
'price' => $price,
'reject' => $reject,
'sa_price' => $price,
'steamid' => $user['steamid']);
}
$array = array(
'error' => 'none',
'fromcache' => false,
'items' => $items,
'success' => true);
if(isset($_COOKIE['tid'])) {
$sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
if($sql->rowCount() != 0) {
$row = $sql->fetch();
$array['code'] = $row['code'];
$array['amount'] = $row['summa'];
$array['tid'] = $row['id'];
$array['bot'] = "Bot #".$row['bot_id'];
} else {
setcookie("tid", "", time() - 3600, '/');
}
}
file_put_contents('cache/'.$user['steamid'].'.txt', serialize($array), LOCK_EX);
exit(json_encode($array));
break;
I am trying to get people steam csgo inventory and put into an array. This works perfectly. Could someone help me figure out how to add a not tradeable tag. My plan is to add the item to the array even if not tradeable. I currently have it so if the item isnt worth < $0.30 then call it junk and ignore the press when clicked on. So something like if (!tradable) then mark as "trade locked" and ignore the press. Thank you.

PHP experience system // simple

As a begginer in php programming language i'm playing with the code, working on localhost and i did some little projects.Now i am trying to do an experience system as simple as i can, i am stuck at this part and i don't know what i am doing wrong.Some suggestions?
What i am doing wrong?
The code.
function update_user_xp($user_id, $xp_ammount){
global $db;
$params = array('user_id' => $user_id);
$users = $db->rawQuery("SELECT * FROM users_xp WHERE user_id = ?", $params);
$data = array(
'user_xp_amount' => $xp_ammount + $users[0]['user_xp_amount'],
'user_id' => $user_id
);
$db->where ('user_id', $data['user_id']);
if ($db->update ('users_xp', $data)){
$xpReceived = 'You have received '.$xp_ammount.' points of experience! Have a total of '.$data['user_xp_amount'].' points of experience.';
} else {
$xpReceived = $db->getLastError();
}
return $xpReceived;
}
//update_user_xp(4, 10); // user_id: 4, update with 10 points
function get_user_xp ($user_id){
global $db;
$params = array('user_id' => $user_id);
$user = $db->rawQueryOne ('SELECT * FROM users_xp WHERE user_id=?', $params);
$xp = $user['user_xp_amount'];
return $xp;
}
function xp_need () {
global $db;
$xpBarNeed = $db->rawQuery("SELECT `level`, `expneeded` FROM `experience_level`");
foreach ($xpBarNeed as $key => $value) {
$output[] = $value;
}
return $output;
}
$xpn = xp_need();
$userXP = get_user_xp(4);
for($i = 0; $i < count($xpn); $i++){
if($xpn[$i]['expneeded'] == $userXP)
{
//This part is working well
print 'You are level <b>' . $xpn[$i]['level'].'</b>';
} else {
if ($userXP > $xpn[$i]['expneeded'] && $userXP >= $xpn[$i]['expneeded'])
{
//This is the part that doesn t work,
$diffEXP = $xpn[$i]['expneeded'] -= $userXP;
print 'You need more exp '. $diffEXP.'</br>';
}
}
}
This is how i am seeing in the page.
https://prnt.sc/u7z18u
Please note that my solution is not the best or say a well-optimized solution at the time of writing. I will try to optimize it in the near future. For the time being, you can use this:
<?php
$xpn = xp_need();
$userXP = get_user_xp(4);
$level = 0;
$nextExp = 0;
for ($i = count($xpn) - 1;$i >= 0;$i--)
{
if ($userXP >= $xpn[$i]['expneeded'])
{
$level = $xpn[$i]['level'];
$nextExp = $xpn[$i + 1]['expneeded'];
break;
}
}
$expNeeded = $nextExp - $userXP;
$percentage = round(($userXP/$nextExp) * 100);
echo "Current level: " . $level;
echo "<br/>Exp needed for the next level (" . ($level + 1) . "): " . $expNeeded;
echo "<br/>Exp achieved percentage for the next level: " . $percentage;
?>

php foreach loop I am doing something wrong

Like for example, I have the following code
if ($result == 1) {
foreach ($records as $record) {
$request_date = $record['date'];
$request_starttime = $record['start_time'];
echo $request_date . " " . $request_starttime;
}
throw new UserException("Unfortunately, this slot is already booked,please check another slot");
} else {
//do something else
}
Here exception is showing fine, but the echo code before that in the block is not displaying on the page.
How I can achieve this?
The result of print_r($slots)
Array
(
[0] => 2018-12-12 12:45:00
)
Array
(
[0] => 2018-12-12 12:45:00
[1] => 2018-12-12 13:00:00
)
Array
(
[0] => 2018-12-12 12:45:00
[1] => 2018-12-12 13:00:00
[2] => 2018-12-12 13:15:00
)
Array
(
[0] => 2018-12-12 12:45:00
[1] => 2018-12-12 13:00:00
[2] => 2018-12-12 13:15:00
[3] => 2018-12-12 13:30:00
)
I have added the print_r($slots) just before the throw new userException line.
The more detailed code block is like this:
foreach ($order_item as $key => $value) {
$order = new OrderItem();
$class_info = ClassDuration::find()->where(['id' => $value['id']])->one();
$end_date = date('Y-m-d', strtotime($model->create_date));
//$p_price = $value['price'];
$order->cd_id = $value['id'];
$order->user_id = $UserId;
$order->location_id = $value['location_id'];
$order->instructor_id = $value['instructor_id'];
$order->date = $value['date1'];
$order->start_time = $value['starttime'];
$order->end_time = date("h:i",strtotime($value['endtime']));
//$order->price = $p_price * $value['q'];
$order->order_id = $model->id;
$instructor=$value['instructor_id'];
$date=$value['date1'];
$starttime =$value['starttime'];
$query = Yii::$app->db->createCommand("SELECT IF(EXISTS(SELECT * FROM `order_item` WHERE `instructor_id`='$instructor' and `date` = '$date' AND `start_time` = '$starttime'), 1, 0)");
$query1 = Yii::$app->db->createCommand("SELECT * FROM `order_item` WHERE exists(select * FROM dual where `instructor_id`='$instructor' and `date` = '$date' AND `start_time` = '$starttime')");
$records=$query1->queryAll();
$result=$query->queryScalar();
//var_dump($result);exit;
if ($result == 1) {
foreach ($records as $record) {
$request_date = $record['date'];
$request_starttime = $record['start_time'];
$slots[] = $request_date . " " . $request_starttime;
}
print_r($slots);
$userMessage = "Unfortunately, this slot is already booked,please check another slot." . implode("<br />", $slots);
//throw new UserException($userMessage);
//echo $userMessage;
}else{
//$order->save();
}
// $grand_total = $grand_total + $order->price;
$ttl_dis = $ttl_dis;
}
You are trying to list the slots that are retrieved as already booked by another user inside $records, as the part of the text that you are showing in the exception, if that is correct then the exception will not allow you to show any other text except the one mentioned inside the exception message you should append the text with the exception message and then you can display it along with the message.
if ($result == 1) {
foreach ($records as $record) {
$request_date = $record['date'];
$request_starttime = $record['start_time'];
$slots[] = $request_date . " " . $request_starttime;
}
$userMessage = "Unfortunately, this slot is already booked,please check another slot." . implode("<br />", $slots);
throw new UserException($userMessage);
} else {
//do something else
}
Update
you should check for the slots before you save anything in the model and redirect to the view see the below code i added an extra function to checkSlots()
public function actionCheckout() {
if( Yii::$app->user->isGuest ){
return $this->redirect(['/site/login-popup']);
}
$session = Yii::$app->session;
$model = new Order();
//$profile = UserProfile::findOne(24);//(['id' => 27])->all();//->where(['id'=>Yii::$app->user->identity->id])->one();
$user = User::findOne(['id' => Yii::$app->user->identity->id]);
$profile = UserProfile::findOne(['user_id' => Yii::$app->user->identity->id]);
$billinginfo = UserBillingInfo::findOne(['user_id' => Yii::$app->user->identity->id]);
$userchildren = UserChildren::findOne(['user_id' => Yii::$app->user->identity->id]);
$modelsKids = $user->kids;
//var_dump($modelsKids);exit;
//Customer::findOne(10);
// var_dump($profile->zipcode);exit;
$model->status = "unpaid";
$model->first_name = Yii::$app->user->identity->first_name;
$model->last_name = Yii::$app->user->identity->last_name;
$model->mobile = Yii::$app->user->identity->phone;
$model->email = Yii::$app->user->identity->email;
$model->address = isset($profile->street1) ? $profile->street1 : '';
$model->city = isset($profile->city) ? $profile->city : '';
$model->state = isset($profile->state) ? $profile->state : '';
$model->post_code = isset($profile->zipcode) ? $profile->zipcode : '';
$pp = new PaypalPayment();
$st = Yii::$app->getTable;
$site_name = $st->settings('general', 'site_name');
if( Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) ){
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
//$order_item = \Yii::$app->getRequest()->getCookies()->getValue('order_item');
$order_item = $session['value'];
if( count($order_item) <= 0 ){
return $this->goHome();
}
$total = 0;
for( $x = 0; $x < count($order_item); $x++ ){
// $cart_p_p = $order_item[$x]['price'];
// $total = $total + $cart_p_p * $order_item[$x]['q'];
}
if( Yii::$app->user->isGuest ){
return $this->render('checkout', [
'model' => $model,
]);
}
$UserId = Yii::$app->user->identity->id;
//check if all slots are available
$allSlotsAvailable = $this->checkSlots($order_item);
if( $model->load(Yii::$app->request->post()) && $allSlotsAvailable ){
$user = User::findOne(['id' => Yii::$app->user->identity->id]);
$profile = UserProfile::findOne(['user_id' => $user]);
if( !empty($UserProfile) ){
$profile = UserProfile::findOne(['user_id' => $user]);
} else{
$profile = new UserProfile();
}
$model->order_number = date('ymdhis');
$model->create_date = date('Y-m-d H:i:s');
$model->status = 1;
$model->create_by = $UserId;
// $model->order_amount = $total;
//var_dump($_REQUEST);
$user->phone = $_REQUEST['Order']['mobile'];
$user->first_name = $_REQUEST['Order']['first_name'];
$user->last_name = $_REQUEST['Order']['last_name'];
$profile->user_id = $user->id;
$profile->mobile = $_REQUEST['Order']['mobile'];
$profile->street1 = $_REQUEST['Order']['address'];
$profile->city = $_REQUEST['Order']['city'];
$profile->state = $_REQUEST['Order']['state'];
$profile->zipcode = $_REQUEST['Order']['post_code'];
$profile->save(false);
if( !empty($_REQUEST['Order']['kids']) ){
$model->kids = serialize($_REQUEST['Order']['kids']);
}
$model->save();
$user->save();
$model->orderUpdate($model->id, 1, NULL);
$grand_total = 0;
$ttl_dis = 0;
foreach( $order_item as $key => $value ){
$order = new OrderItem();
$class_info = ClassDuration::find()->where(['id' => $value['id']])->one();
$end_date = date('Y-m-d', strtotime($model->create_date));
//$p_price = $value['price'];
$order->cd_id = $value['id'];
$order->user_id = $UserId;
$order->location_id = $value['location_id'];
$order->instructor_id = $value['instructor_id'];
$order->date = $value['date1'];
$order->start_time = $value['starttime'];
$order->end_time = date("h:i", strtotime($value['endtime']));
//$order->price = $p_price * $value['q'];
$order->order_id = $model->id;
$order->save();
// $grand_total = $grand_total + $order->price;
$ttl_dis = $ttl_dis;
}
$model->order_amount = $grand_total;
$model->save();
$session->remove('date1');
$session->remove('time1');
Yii::$app->session->setFlash('orderPlaced');
$link = '#';
if( $model->payment_method == 'paypal' ){
$new_array = $order_item;
$pp->addMultipleItems($new_array);
return $pp->getCheckoutForm($model->id);
} elseif( $model->payment_method == 'invoice' ){
$content = $this->renderPartial('_invoice', ['model' => $model]);
//var_dump($content);
$filename = 'web/customer-invoice/invoice' . $model->id . '.pdf';
$pdf = new Pdf(['format' => Pdf::FORMAT_A4]);
$mpdf = $pdf->api;
$stylesheet = file_get_contents('themes/common/css/print/invoice.css');
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHtml($content);
$mpdf->Output($filename, 'F');
$from_email = $st->settings('email', 'from_email');
$from_name = $st->settings('email', 'from_name');
$user = User::findOne($UserId);
$to = $user['email'];
$email_template = $st->email_template(10);
\Yii::$app->mailer->compose('template', ['id' => 10, 'user_id' => $UserId,
'email_template' => $email_template,
'model' => $model,
'link' => $link])
->setFrom([$from_email => $from_name])
->setTo($to)
->setSubject($email_template['subject'] . ' ' . $site_name)
->attach($filename)
->send();
} elseif( $model->payment_method == 'booking' ){
$admin = User::find()->select('email')->where(['user_role' => 'admin'])->asArray()->all();
$admin = ArrayHelper::getColumn($admin, 'email');
$content = $this->renderPartial('_booking', ['model' => $model]);
// var_dump($content);
$filename = 'web/customer-booking/booking' . $model->id . '.pdf';
$pdf = new Pdf(['format' => Pdf::FORMAT_A4]);
$mpdf = $pdf->api;
$stylesheet = file_get_contents('themes/common/css/print/invoice.css');
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHtml($content);
$mpdf->Output($filename, 'F');
$from_email = $st->settings('email', 'from_email');
$from_name = $st->settings('email', 'from_name');
$user = User::findOne($UserId);
$orderid = Order::find(['created_by' => $user->id])->select('id')->orderBy('create_date DESC')->one();
$instructor_id = OrderItem::find()->select('instructor_id')->where(['order_id' => $orderid])->distinct();
$Instructor = User::findOne($instructor_id);
// var_dump($instructor_id);exit;
// $admin = ArrayHelper::getColumn($admin, 'email');
$to = $user['email'];
$instructor_email = $Instructor['email'];
$admin[] = $to;
$admin[] = $instructor_email;
// $to .= $Instructor['email'];
$email_template = $st->email_template(10);
\Yii::$app->mailer->compose('template', ['id' => 10, 'user_id' => $UserId,
'email_template' => $email_template,
'model' => $model,
'link' => $link])
->setFrom([$from_email => $from_name])
->setTo($admin)
->setSubject($email_template['subject'] . ' ' . $site_name)
->attach($filename)
->send();
}
//Yii::$app->response->cookies->remove('order_item');
unset($session['value']);
return $this->redirect(Yii::getAlias('#web') . '/order/view?id=' . $model->id);
//return $this->redirect('result');
} else{
return $this->render('checkout', [
'model' => $model,
// 'modelsKids' => (empty($modelsKids)) ? [new UserChildren] : $modelsKids,
]);
}
}
private function checkSlots($order_items) {
$slots = [];
foreach( $order_items as $item ){
$instructor = $item['instructor_id'];
$date = $item['date1'];
$starttime = $item['starttime'];
$query = Yii::$app->db->createCommand("SELECT IF(EXISTS(SELECT * FROM `order_item` WHERE `instructor_id`='$instructor' and `date` = '$date' AND `start_time` = '$starttime'), 1, 0)");
$result = $query->queryScalar();
if( $result == 1 ){
$slots[] = $date . " " . $starttime;
}
}
if( sizeof($slots) ){
Yii::$app->session->setFlash('error', "Unfortunately, this slot is already booked,please check another slot<br />".implode("<br />", $slots));
return false;
} else{
return true;
}
}
in the function checkSlots($order_items) you will see that I have removed one of your queries
$query1 = Yii::$app->db->createCommand("SELECT * FROM `order_item` WHERE exists(select * FROM dual where `instructor_id`='$instructor' and `date` = '$date' AND `start_time` = '$starttime')");
as its un-necessary to retrieve the records for the same date and start_time that you are querying with, and just use the result from the first query and add the date and start time to the $slots and once all records are checked and if there are any reserved slots the method returns false and the view will be displayed along with the flash message that will show all those slots that are reserved.

how to more than one module in laravel using array and forloop

$module_name = array(
"Customerdetails",
"Customercomments",
"Complaints",
"Customerquotes",
"Systemconfiguration",
"regulatoryreports",
"Customermain",
"Customerdomestic"
);
for ($i = 0; $i < count($module_name); $i++) {
$row = DB::table('tb_module')->where('module_name', $module_name[$i])->get();
if (count($row) <= 0) {
return Redirect::to('/Grouplevel')
->with('message', SiteHelpers::alert('error', 'Can not find module'));
}
//print_r($row);
$row = $row[0];
$row_name[$i] = $row;
$module[$i] = $this->module;
$config = SiteHelpers::CF_decode_json($row->module_config);
$tasks = array(
'is_view' => 'View ',
'is_detail' => 'Detail',
'is_add' => 'Add ',
'is_edit' => 'Edit ',
'is_remove' => 'Remove ',
);
/* Update permission global / own access new ver 1.1
Adding new param is_global
End Update permission global / own access new ver 1.1
*/
if (isset($config['tasks'])) {
foreach ($config['tasks'] as $row) {
$tasks[$row['item']] = $row['title'];
}
}
$this->data['tasks'] = $tasks;
$this->data['groups'] = DB::table('tb_groups')->get();
$access = array();
foreach ($this->data['groups'] as $r) {
// $GA = $this->model->gAccessss($this->uri->rsegment(3),$row['group_id']);
$group = ($r->group_id != null ? "and group_id ='" . $r->group_id . "'" : "");
$GA = DB::select("SELECT * FROM tb_groups_access where module_id ='" . $row->module_id . "' $group");
if (count($GA) >= 1) {
$GA = $GA[0];
}
$access_data = (isset($GA->access_data) ? json_decode($GA->access_data, true) : array());
$rows = array();
//$access_data = json_decode($AD,true);
$rows[$i]['group_id'] = $r->group_id;
$rows[$i]['group_name'] = $r->name;
foreach ($tasks as $item => $val) {
$rows[$i][$item] = (isset($access_data[$item]) && $access_data[$item] == 1 ? 1 : 0);
}
$access[$r->name] = $rows[$i];
$id[$i] = $row->module_id;
}
}
for ($i = 0; $i < count($module_name); $i++) {
$this->data['row'] = $row_name[$i];
$this->data['module'] = $module[$i];
$this->data['module_name'] = $row_name[$i]->module_name;
$this->data['access'] = $access;
$this->data['groups_access'] = DB::select("select * from tb_groups_access where module_id ='" . $id[$i] . "'");
$this->layout->nest('content', 'Grouplevel.index', $this->data)
->with('menus', SiteHelpers::menus());
}

How to get all the results where parent is an item from an array

I have an array that consists names of parents ,I want to get all the results where any of the name is a parent.Here is my code.I am not able to get the list of names where parent is equal to the names in district array.
Here is my complete code.
<?php
$functionname = 'core_course_get_categories';
$username = array('key' => 'name', 'value' => '2016');
$params = array('criteria' => array($username));
$server_url = 'localhost/moodle' . '/webservice/rest/server.php' . '?wstoken=' . '9cdaccf3a7ad2f0f94922ccfd02559f4' . '&wsfunction=' . $functionname;
$rest_format = 'json';
require_once('curl.inc');
$curl = new curl;
$rest_format = ($rest_format == 'json') ? '&moodlewsrestformat=' . $rest_format : '';
$resp = $curl->post($server_url . $rest_format, $params);
$res = json_decode($resp);
// drupal_set_message('<pre>'. dpm($res) .'</pre>');
$district = array();
$Ctsc = array();
$School = array();
$Grade = array();
$parent = array();
foreach ($res as $r) {
$a = $r->parent;
$c = $r->name;
if ($a == 0) {
$b = $r->id;
var_export($b);
}
}
foreach ($res as $r) {
if ($r->parent == $b) {
//$dist=$r->name;
$district[] = $r->name;
}
}
$Ctsc[] = $r->description;
$School[] = $r->sortorder;
$Grade[] = $r->depth;
foreach ($res as $r) {
$q = $r->name;
if (in_array($q['parent'], $district)) {
$Ctsc[] = $q->name;
dpm($Ctsc);
}
if ($Ctsc['parent'] == $district) {
dpm($Ctsc);
}
}
Usage of in_array() is wrong.
Instead of
if(in_array($q['parent'] == $district)){ ... }
use
if(in_array($q['parent'], $district)){ ... }

Categories