foreach

Checkboxes with watchdog_severity_levels()

て烟熏妆下的殇ゞ 提交于 2020-01-17 12:23:06
问题 I have this code that gets me out some checkboxes with the watchdog severities: /** * Checkbox for errors, alerts, e.t.c */ foreach (watchdog_severity_levels() as $severity => $description) { $key = 'severity_errors' . $severity; $form['severity_errors'][$key] = array( '#type' => 'checkbox', '#title' => t('@description', array('@description' => drupal_ucfirst($description))), '#default_value' => variable_get($key, array()), ); return system_settings_form($form); } I set this $key in my code

Properly reading the data of .csv files in php

有些话、适合烂在心里 提交于 2020-01-17 05:35:10
问题 I have a working system on which I get the data of two .csv file. And save all the data into array and then compare some of the data existing on both csv file. The system works well but later I found out that some of the rows doesn't display on the array. I think I don't use the proper code in reading a csv file. I want to edit/improve the system. This is my code on reading or getting the data from csv file. $thedata = array(); $data = file("upload/payment.csv"); foreach ($data as $deposit){

How to count the result of a if loop within foreach loop

纵然是瞬间 提交于 2020-01-17 03:39:25
问题 Is there a better way to be able to count the amounts of empty groups than using this method and then calling $count + 1 for each result? I tried to mess around with $123.count but it kept returning 0 $Groups = Get-ADGroup -Properties * -Filter * | where { $_.Members.Count -eq 0} $123= Foreach($G In $Groups) { $Membership = Get-ADGroupMember -Identity $G.Name If($Membership.count -eq 0){ $Count = $count + 1 } } 回答1: Get-ADGroup can do much of what you ask without going away from AD. Getting

Assignment same property values to other

[亡魂溺海] 提交于 2020-01-16 13:05:08
问题 I have different classes sharing some properties of same type and name. I wish to assign same property values to each other. I explain my intention better in comments in the following pseudo-code. Is it possible in C#? Ponder that there are a plethora of common properties but in unrelated classes, must we assign them one-by-one? Second case is about sharing same properties but some of them may be nullable, who knows! Side note: the classes already exist, cannot be altered, touched. Kinda

Exiting a foreach loop and retrieve result

独自空忆成欢 提交于 2020-01-16 11:53:07
问题 I'm working on a little project and I've gone brain dead, so I'm hoping someone here can help me defeat my coders block. I'm trying to create a page using php that changes its content display depending on what (if any) value is passed to the page (Locations). I have created a safelist array which I've stored the different locations. First I check any value passed against the safe list, if its a match I display one set of content. If it doesn't match I'm running a similarity test to check if

How to do sum of array item's value until not reached at specified value?

丶灬走出姿态 提交于 2020-01-16 11:27:06
问题 I want to do sum of array item's value until not reached at specified value. Let me explain in details. I want 20 k.g value in each box , So following is my array. Array ( [0] => Array ( [product_id] => 2 [customer_id] => 1820 [order_id] => M-AAH-959 [quantity] => 5 [weight] => 1.3 [cubic] => 0.00267 [total_weight] => 6.5 [total_cubic] => 0.00267 ) [1] => Array ( [product_id] => 3 [customer_id] => 1820 [order_id] => M-AAH-959 [quantity] => 6 [weight] => 1.5 [cubic] => 0.00348 [total_weight] =

JQuery not registering Button click

佐手、 提交于 2020-01-16 04:47:06
问题 I have a page that displays a list of products. The user can select the quantity of a product to order and then click the order button. This should place a reference to the quantity and the product ID in a Cookie. However currently the button is not even being registered. When I click on it nothing happens. If I place the button outside of the foreach loop then it works. Does anyone know what is going on? Below is the code for the list of products <?php if($products): ?> <ul> <?php foreach(

PHP prevent foreach loop from overwriting object

Deadly 提交于 2020-01-16 04:23:05
问题 This is the fourth time I've tried writing this question, so please bear with me. I have a PHP object that comes from a DB Query which pulls back the following data: [1] => stdClass Object ( [eventId] => 11 [eventName] => Second Event [...] [eventChildren] => Array ( [0] => stdClass Object ( [childId] => 8 [childName] => Jane Doe [...] [gifts] => Array ( [0] => stdClass Object ( [giftId] => 73 [giftName] => My two front teeth [childId] => 8 [userId] => 1 [eventId] => 11 ) [1] => stdClass

Foreach changed row

久未见 提交于 2020-01-16 00:44:47
问题 I'm trying to manipulate my MySQL results to create an XML file. This question is not to do with the latter part of that task, but the former: manipulating the SQL query results in PHP. I want to create a foreach statement which will group the results into the column value they share ('group_id'). (I might have three rows with the same column value, and five rows with another column value.) I imagine having one foreach construct inside another one. The parent one should loop through the

Pass array keys and values to Mysql Query String

不打扰是莪最后的温柔 提交于 2020-01-15 23:03:57
问题 I have an array represents WHERE clause of my SQL query. $qWhere= array("cName" => "Turgay Metal", "cTelephone" => "5556162"); my function is: (simplified) <?php function getAll($tableName,$qWhere="") { $qWhere = $qWhere == "" ? $qWhere : (" WHERE " . $qWhere); $sql = "SELECT * FROM $tableName $qWhere";} So i need to write another function to kinda serialize array with foreach as $k = '$v' and then join " AND " then return the string. Finally supply the string into main function: function