foreach

Return number in array that is greater than X

旧街凉风 提交于 2020-01-25 02:20:31
问题 The following code automagically finds the highest price on a page: $vw_link = get_field('shop_link'); $ch = curl_init($vw_link); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $cl = curl_exec($ch); $dom = new DOMDocument(); @$dom->loadHTML($cl); $xpath = new DOMXpath($dom); $price = $xpath->query("//span[@class='price']"); foreach($price as $value) { $vw_array[] = floatval(str_replace('$', '', $value->nodeValue)); update_field('shop_price',max($vw_array)); } What would be the best thing

SSIS foreach loop enumerator empty is empty - only when deployed

本小妞迷上赌 提交于 2020-01-24 22:08:53
问题 In SSIS I am using a Foreach loop container to loop through a list of files. My project works fine in locally - it finds the files, but when I deploy to SSMS and run it, it gives the error: The for each file enumerator is empty. The for each file enumerator did not find any files that match the pattern, or specified directory was empty. The directory I am pointing to is a network location I have permissions on this directory. Has anyone experience this issue before? 来源: https://stackoverflow

Changing foreach iteration variable and implementation differences between C# and C++/CLI

馋奶兔 提交于 2020-01-24 20:26:06
问题 Consider the following C# code. string[] stringArray = new string[10]; foreach (string s in stringArray) s = "a new string"; // Compiler error - Can't assign to foreach iteration variable Now consider the following valid C++/CLI code. array<String^>^ stringArray = gcnew array<String^>(10); for each(String^% s in stringArray) s = "a new string"; When foreach is used with array type, compiler translates it into normal for loop. This implementation is same for C# and C++/CLI. So I wonder if C++

Javascript ForEach Function does not work in IE

血红的双手。 提交于 2020-01-24 13:52:26
问题 how could I write the following Code that it is supported in all browsers? Because it seems that the forEach-Function is not supported in IE8... digits.forEach( function( value, index ) { // create a span with initial conditions var span = $( '<span>', { 'class': 'digit0', 'data': { 'current': 0, 'goal' : value } } ); // append span to the div#number span.appendTo( $( 'div#number' ) ); // call countUp after interval multiplied by the index of this span setTimeout( function() { countUp.call(

Javascript ForEach Function does not work in IE

邮差的信 提交于 2020-01-24 13:52:05
问题 how could I write the following Code that it is supported in all browsers? Because it seems that the forEach-Function is not supported in IE8... digits.forEach( function( value, index ) { // create a span with initial conditions var span = $( '<span>', { 'class': 'digit0', 'data': { 'current': 0, 'goal' : value } } ); // append span to the div#number span.appendTo( $( 'div#number' ) ); // call countUp after interval multiplied by the index of this span setTimeout( function() { countUp.call(

How to export many variables and functions from global environment to foreach loop?

别等时光非礼了梦想. 提交于 2020-01-24 09:32:06
问题 How can I export the global environment for the beginning of each parallel simulation in foreach? The following code is part of a function that is called to run the simulations. num.cores <- detectCores()-1 cluztrr <- makeCluster(num.cores) registerDoParallel(cl = cluztrr) sim.result.list <- foreach(r = 1:simulations, .combine = list, .multicombine = TRUE, ) %dopar% { #...tons of calculations using many variables... list(vals1, vals2, vals3) } stopCluster(cluztrr) Is it necessary to use

Powershell Only Add to Array if it doesn't exist

 ̄綄美尐妖づ 提交于 2020-01-24 02:41:09
问题 In PowerShell v2, I'm trying to add only unique values to an array. I've tried using an if statement that says, roughly, If (-not $Array -contains 'SomeValue'), then add the value, but this only ever works the first time. I've put a simple code snippet that shows what I'm doing that doesn't work and what I've done as a workaround that does work. Can someone please let me know where my issue is? Clear-Host $Words = @('Hello', 'World', 'Hello') # This will not work $IncorrectArray = @() ForEach

In VBA code,how to add values to a listbox using for each cell approach with defining a range End(XlDown)?

瘦欲@ 提交于 2020-01-24 00:51:07
问题 I have created a macro file with Forms and Word to Excel. In this coding fewthings are not working as per my expectation. Get unique Employee Name from Excel data base. I want to add unique employee names from excel database and get is saved in a sheet. After that those values to be added to list box. Here i cannot define a range like "A1:A10".. I want to choose the data from A1 to end data. If for each cell approach will not work, please help in do while approach I need help in defining the

A more efficient way of binding a big insert or update?

荒凉一梦 提交于 2020-01-23 16:47:14
问题 Ok so im new to binding, here is some code that works. I learned this format from a tutorial but i imagine there is more efficent ways to do it. In my example there is 4 names but in reality i will be doing a lot of inserts and updates in a project im working on that will have 20 or so fields. I like this approach for its clarity but obviously when your talking 20 fields or more it does take a lot of real estate. Lets look at my code first. Here are the functions it uses: // prepare the

Read and print json array in php

狂风中的少年 提交于 2020-01-23 16:32:11
问题 I have a JSON array like below. I want to print only the values of the name. But I am getting undefined index name and getting value of name.below is my json. [{"docId":{"id":"57dd70252a896558e573a0c8"},"docProfile":{"name":"gowtham","gender":null,"email":null,"mobile":"7406339908"},"docLocalInfo":{"username":"gowtham","otp":934343,"newPasswordToken":null,"tempMobile":"","adminVerfiy":null},"privateInfo":{"mciNumber":null,"aadharNumber":null,"panNumber":null},"tempHospitals":[],"bankInfo"