w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Sectioning code in sql-server
Not natively, you'll need a third party tool for that. SSMS Tools Pack by Mladen Prajdić gives you #region functionality, along with a lot of others. Not free, but very, very good.

Categories : Sql Server

Semantic sectioning and the effects of an aside advertisement’s own headline
will search engines interpret my document as being all about ads? Some search engines are certainly smart enough to understand it, other search engines probably not. It depends on the specific search engine and its current interpretation, as it could change daily. What is The Right Thing To Do™ here? This depends on your priorities. If we understand the HTML specification as agreement between web authors and user-agent programmers (including browsers and services like search engines), the right thing would be to write your markup according to the HTML spec (and related specs like WCAG etc.). Search engines should follow, and not try to dominate how web authors should markup their documents. An alternative to your markup could be: <aside> <small>Advertisem

Categories : HTML

Dynamic SQL, comparing two records one column at a time
You are on the right track. But it is quite some more programming work to do. Read the old and new table in a join linking it with the correct primary key and loop through it. You can use DMBS_SQL package to build a dynamic cursor and loop through the tables.

Categories : Oracle

Stackoverflow exception when comparing two dynamic types
Please, read your compiler warnings :) You haven't provided a definition for the Typeable typeclass's typeOf method for DynamicLocation, and toDyn calls typeOf. So this definitely shouldn't work -- if you try just toDyn Loc_1, you'll get an exception. But why an infinite loop? It's because you also haven't defined (==) for Dynamic, and (==) and (/=) are defined in terms of each other in GHC.Classes. GHC doesn't attempt to resolve such infinite recursion in default method declarations, so you unfortunately don't get a warning. What to do? I suggest letting GHC derive the Typeable instance for you: {-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-} data DynamicLocation = Loc_1 | Loc_2 deriving (Eq,Show) deriving instance Typeable DynamicLocation or, more sensible: {-# LANGUAGE De

Categories : Haskell

Comparing dynamic fields of objects using equals and hashCode methods
I think I have found the solution and its working for me. Please let me know if there could be the simple or any other way out finding the solution for this problem. The code snippet is: package mypack; import java.util.*; public class TableClass { public List<ColWithData> cwdList; public List<ColWithData> getCwdList() { return cwdList; } public void setCwdList(List<ColWithData> cwdList) { this.cwdList = cwdList; } @Override public boolean equals(Object obj) { TableClass tClass = (TableClass) obj; boolean returnVal = true; for(ColWithData cwd: this.getCwdList()){ for(ColWithData innerCwd: tClass.getCwdList()){ if(cwd.getCol().equalsIgnoreCase(innerCwd.getCol())){

Categories : Java

comparing dynamic number of lists (non-equal length) for common entries in Python
From all your lists you can create one set that will contain all the items that are present in all lists with the function intersection() This works starting with Python 2.6 and you'll have to covnert the lists to sets first. http://docs.python.org/2/library/stdtypes.html#set.intersection

Categories : Python

Dynamic pointing array to a dynamic 2 dimensions array?
Allocation in your code is wrong! Do like this: char** players = malloc(sizeof(char*) * numOfPlayers); ^ remove one * for (i=0 ; i<numOfPlayers ; i++){ players[i] = malloc(sizeof(char)* 10); // each player 1st D array // ^ remove * it should be char } note: sizeof(char) != sizeof(char*). You don't need second nested for loop too. (just above code is fine) Also avoid casting return value from malloc/calloc in C Note A mistake in your code is that numOfPlayers is not initialized (you are trying with garbage value). Comment: But then, i only have 2D array. i need an array that each cell of him points to a 2D array like so... you misunderstood my question Read if you wants

Categories : C

Comparing array entries
Use java.util.Random class for randomly selecting a winner from nameArray Random rand=new Random() int winnerIndex=rand.nextInt(nameArray.length); then JOptionPane.showMessageDialog(null, "The winner for today's raffle " + "is: " + nameArray[winnerIndex], "Winner", JOptionPane.WARNING_MESSAGE);

Categories : Java

Comparing a NodeList to an Array of element id's
Instead having an array of id's it would be easier to use an associative array. This will make your second loop significantly less-cumbersome: var ids = { aa0: true, aa1: true, aa7: true, aa8: true }; var remove = []; var add = []; for(var id in ids) if(ids.hasOwnProperty(id)) { if(document.getElementById(id) === null) { remove.push(id); } } for(var i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if(typeof node.id !== undefined && !ids[node.id]) { remove.push(node.id); } } The if in the second loop can be changed to use an indexOf the following if you were using an array of id's: if(typeof node.id !== undefined && ids.indexOf(node.id) > -1) { remove.push(node.id) } Performance-wise the first one i

Categories : Javascript

C++ comparing a string with an array of strings
With find: #include <algorithm> #include <iterator> auto it = std::find(std::begin(food), std::end(food), word); if (it != std::end(food)) { // found *it } else { // not found }

Categories : C++

PHP - Comparing Array Keys and Values
There is no need to iterate over an array when you know the key you are looking for. Simply check for the value using the key. if ( $mergedArrays[$username] == $password ) { return TRUE; }

Categories : PHP

Splitting array by comparing keys in PHP
Try like foreach($my_arr as $key=>$value) { $new_key = explode('.',$key); if($new_key[0] == "datebase1" && $new_key[1] == "table1") { $arr1[$key] = $value; } elseif ($new_key[0] == "datebase2" && $new_key[1] == "table2") { $arr2[$key] = $value; } } Or you can try like foreach($my_arr as $key=>$value) { $new_key = explode('.',$key); $new_arr[$new_key[0]][$new_key[1]][] = array($key=>$value); } print_r($new_arr); Output : Array ( [database1] => Array ( [table1] => Array ( [0] => Array ( [database1.table1.fieldname] => test ) [1] => Array (

Categories : PHP

C++ Comparing inner values in a 2D multidimensional array
The naive and simplest solution is to have two loops, one to check if all three are equal to 'O' and if not then run another to check if all three are equal to 'X'. Something like the following pseudo-code: winner = check_winner('O'); if (winner != 'O') winner = check_winner('X'); if (winner != '-') std::cout << "The winner is " << winner << ' '; The function check_winner will of course do the actual check, and returns the symbol or '-' if no winner.

Categories : C++

Comparing dates after a foreach php array
You have a typo in the following. It should be $v1 instead of $v: $event = 'Aug 8, 2013'; if($event>$v && !($event<$v1)) { echo "Event belongs here on $v1"; }else { echo "Event does not belongs here it's to late on the on $v1"; } Also, you are comparing string values. You need to convert them to something that you can compare such as timestamps: $event = strtotime('Aug 8, 2013'); $vts = strtotime($v1); if($event > $vts) { echo "Event belongs here on $v1"; }else { echo "Event does not belongs here it's to late on the on $v1"; }

Categories : PHP

jQuery text() not comparing to an array
New edit: just replace var t = q.text(); with var t = $.trim(q.text()); as @adeneo suggests: $('#categories').on('click','img',function() { var q = $(this).parent(); var t = $.trim( q.text() ); loop( t ); }); function loop(param) { // alert( param + ' ' + exceptions[0] ); //alerts the exact same value // alert( jQuery.type(param) +' '+ $.type(exceptions[0]) ); //alerts string //above shows that there the same type and value. for (var i=0;i<exceptions.length;i++) { if (exceptions[i] == param) { alert('works!'); } } } Right answer by @adeneo, yet this is one step to debug this kind of bugs: http://jsfiddle.net/AstDerek/X2Cej/ Much hated first answer: Your logic seems wrong, q is an image, t = q.text() is empty

Categories : Jquery

Comparing values within an array to the arithmetic mean of the first and last numbers
The line if(ok==0 && count(v,n)==1) should be if(ok==0 && count(v,n)== n-1). If the first and last are not equal, but one of them is the lowest number, then count(v,n) will return n-1. With your example data with 6 input: 12 245 654 23 652 11. (first + last) / 2 = 11.5 12, 245, 654, 23, and 652 are all greater than 11.5, so count(v,n) returns 5 (e.g. n-1), which indicates that "either the first of the last number is the lowest". edit: The simplest solution would be fixing count() to check if(v[i]<=m) instead of >=. That way it returns the quantity of datum that are less than (first+last)/2. If first==last, it will return 2, if first!==last, it should return 1.

Categories : C++

Comparing values from a javascript array and make sure each value is at least 10 apart
jsFiddle Demo var myArray = [ [364, 124], [192, 272], [209, 217], [332, 227], [241, 273], [356, 387], [104, 185], [361, 380], [297, 390], [371, 311], [191, 293] ]; function distTen(element, index, array) { for (x = 0; x < 10; x++) { if (Math.abs(element[0] - array[x][0]) < 10) array[x][0] += 10; if (Math.abs(element[1] - array[x][1]) < 10) array[x][1] += 10; } } function logIt(element, index, array) { console.log("a[" + index + "] = " + element); } myArray.forEach(distTen); myArray.forEach(logIt); RESULTS a[0] = 394,134 a[1] = 202,302 a[2] = 229,227 a[3] = 342,247 a[4] = 251,303 a[5] = 376,407 a[6] = 114,195 a[7] = 381,390 a[8] = 307,410 a[9] = 401,321 a[10] = 191,293

Categories : Javascript

Comparing array value (int) from database to an integer in if statement
The problem is that your row isn't being received within the scope of your function. function checkSection(){ if ($row['section'] == 1) { return "web/"; } elseif ($row['section'] == 2) { return "email/"; } elseif ($row['section'] == 3){ return "print/"; } return "FAILED/"; } To the function, $row is blank. You need to pass it as a variable to the function for this to work. ie. function checkSection($row){ if ($row['section'] == 1) { return "web/"; } elseif ($row['section'] == 2) { return "email/"; } elseif ($row['section'] == 3){ return "print/"; } return "FAILED/"; } checkSection($row)

Categories : PHP

How to find nearest timestamp by comparing two array
function findResetMate($e,$k, $reset) { $gap = 10E50+1; if ($reset < $e) return false; if (($reset - $e) < $gap) { $gap = ($reset - $e); $mate = $reset; } echo "EVENT : " . date("M d, Y H:i:s",$e) . " -->RESET<-- " . date("M d, Y H:i:s",$reset) . "<br /> "; return true; } foreach($data['Reset'] as $r) { array_walk($data['Occur'], "findResetMate", $r); }

Categories : PHP

C - Comparing string literal with character array
I think this is a perfect starting point for you: http://www.wikihow.com/Compare-Two-Strings-in-C-Programming It's probably written at the right level for you. Good luck and welcome to stackoverflow!

Categories : C

Filter Master Array by comparing against two other arrays
Instead of storing the removed and included objects in an array, store them in an object keyed off the ID. Then you can do: for (var j = 0; j < MASTERARRAY.length; j++) { if (ISOTOPEFILTER.resultsRemovedFromPage[MASTERARRAY[j].id]) { // Do stuff for removed items } if (ISOTOPFILTER.resultsOnPageAfterFiltering[MASTERARRAY[j].id]) { // Do stuff for included items } }

Categories : Javascript

Comparing two list of array based on Date
Any idea why it's not working? In any case, I noticed you use distance.remove(i); and inter.remove(j); when your for loops don't use i and j. Either use a normal for loop, or use the name you gave the item in the advanced for loops. If it's not that, then I also noticed: resultLatency isn't defined in the code you provided. Is it outside of the for loops you provided? DateTime and Seconds don't seem to be standard Java classes, so I assume it's they're custom classes. Maybe there's an issue in there? Just in case, could you show those classes too?

Categories : Java

Merge possible values to array when comparing two arrays
Would this suffice: <?php $array1 = array( 'entry'=>'18', 'mykey'=>'value1', 'something'=>'1' ); $array2 = array( 'entry'=>'18', 'mykey'=>'value2', 'something'=>'1' ); $output = array(); foreach($array1 as $k=>$v){ if(isset($array2[$k]) && $array2[$k] === $v){ $output[$k] = $v; }elseif(isset($array2[$k])){ $output[$k][] = array($v,$array2[$k]); }else{ $output[$k] = $v; } } foreach($array2 as $k=>$v){ if(!array_key_exists($k,$output)){ $output[$k] = $v; } } echo '<pre>',print_r($output),'</pre>'; Edit:I do like the use of array_merge_recursive() mentioned by Ziarno, but the issue is that it will create an array for each key. So I have added the use of array_un

Categories : PHP

Powershell: Comparing multiple values in an array
You could group by Computername, then for each group, sort by LastDate and select the last item. You will have to adjust to meet your formatting needs, but it would look something like this. Import-Csv -Path .computers.csv| group -Property Computername| foreach { $_.group| sort { try { [datetime]$_.LastDate } catch {} }| select -last 1 }| Export-Csv -Path .computers_LastDate.csv -NoTypeInformation

Categories : Arrays

comparing values of array and fill dropdown
I created a jsFiddle which may help you achieve your goal: http://jsfiddle.net/XTdrr/ The initial HTML: <select id="select1" onChange="populateSelect2()"> <option value="">Choose...</option> </select> <br/> <select id="select2"></select> The initial JavaScript variables var array1 = [1, 2, 3]; var array2 = [1, 1, 1, 1, 2, 2, 3, 3]; var select1 = document.getElementById("select1"); var select2 = document.getElementById("select2"); First, it populates the first dropdown list with the values in array1. window.onload = function () { // here we populate select1 with the elements in array1 for (var i = 0; i < array1.length; i++) { var opt = document.createElement('option'); opt.value = array1[i]; opt

Categories : Javascript

Iterate through array comparing dictionary values
(untested): self.tempDataArray = [[NSMutableArray alloc] init]; for (NSUInteger i = 0; i < kDelegate.dataArray.count; i++) { NSDictionary *dict = [kDelegate.dataArray objectAtIndex:i]; NSArray *allValues = [dict allValues]; for (NSUInteger j = 0; j < allValues.count; j++) { NSObject *obj = [allValues objectAtIndex:j]; if ([obj isKindOfClass:[NSString class]]) { NSRange range = [(NSString *)obj rangeOfString:searchString]; if (range.location != NSNotFound) { [self.tempDataArray addObject:dict]; } } } }

Categories : Osx

Comparing javascript array with select:option values
You can do: $('select').click(function() { var clicked = $(this).val(); loop(exceptions, clicked) ? exceptions.push(clicked) : return; }); function loop(array,clicked) { for (var i=0;i<array.length;i++) { if (array[i] == clicked) {return false;} } return true; }

Categories : Javascript

PHP Comparing an array element to a string to determine results
$hr24 = strtotime("-1 days"); $hr72 = strtotime("-3 days"); $older24 = array(); $older72 = array(); foreach ($Output AS $date) { $time = strtotime($date); if ($time < $hr72) { $older72[] = $date; } else if ($time < $hr24) { $older24[] = $date; } } file_put_contents('/folder/test/test24hr_log.txt', serialize($older24)); file_put_contents('/folder/test/test72hr_log.txt', serialize($older72)); http://phpfiddle.org/lite/code/q3r-j5y

Categories : PHP

sorting array with uasort comparing to a string with regex
Won't answer the question as stated but you could use this. It will effectively rank the results based on how close the term is to the beginning of the string. function ($a, $b) use ($term) { return stripos($a, $term) - stripos($b, $term); } This will only work if all of the values have the term somewhere in them (like the results of a like query). Test script: $arr = array("aaTest", "aTest", "AAATest", "Test"); $term = "Test"; uasort($arr, function ($a, $b) use ($term) { return stripos($a, $term) - stripos($b, $term); }); print_r($arr); Test Output: Array ( [3] => Test [1] => aTest [0] => aaTest [2] => AAATest ) UPDATE Changed code to use stripos instead of strpos for case insensitive sorting

Categories : PHP

Manually sorting an array comparing to given list of words
Without seeing an example of the array, it's kind of hard to code, but something like this should work: usort($arr, function ($a, $b){ $ord =array_flip(array ('white', 'blue', 'purple', 'brown', 'black', 'black-red', 'coral', 'white-red', 'red')); return $ord[$b] - $ord[$a]; });

Categories : PHP

Comparing grouped values in a database table with an associative array
I solved this by comparing an imploded string from the arrays with GROUP_CONCAT on the table. Since you can't normally use GROUP_CONCAT in the WHERE clause I had to do a workaround with the FROM clause. <?php $s = ''; foreach($updated as $u){ $s .= $u['pId'] . $u['name'] . 'updated,'; } foreach($deleted as $d){ $s .= $d['pId'] . $d['name'] . 'deleted,'; } foreach($added as $a){ $s .= $a['pId'] . $a['name'] . 'added,'; } //remove last comma $s = rtrim($s, ','); $stmt = $mysqli -> prepare(" SELECT relationId FROM ( SELECT relationId, GROUP_CONCAT(pId, name, changeType ORDER BY changeType DESC, id ASC) AS personConcat FROM pers

Categories : PHP

Jackson parsing JSON containing an array of objects and array of maps w/ dynamic keys
You could probably get around this by writing your own custom deserializer and register it with the object mapper that you are using. This should work as you will have complete control of how each object is deserialized into a User object. See this jackson documentation on how to roll your own deserializer. Would also like to say, if you have control over the json structure - I would change the key value (which I am guessing is an ID for the user) to be a part of the actual json object as opposed to being the key. This will help you avoid the issue all together. For example: "users":{ { "id":"1234", "firstname":"Joe", "lastname":"Smith" }, { "id":"9876", "firstname":"Bob", "lastname":"A

Categories : Java

Why in Excel comparing 1<' or comparing any number to any text with < results in true?
You can refer to Comparing Strings by Using Comparison Operators According to this for your string comparison at < b, the ASCII value of first character 1 is 49 and same for at and b, however the for the second character the ASCII value of 2 is more than the ASCII value of 1, hence the expression at < b return false Also as explained in greater detail in Comparison Operators (Visual Basic), if you defined the primitive types of the variables the behavior get changed, see below Case-1: Sub CompareNumberAndText() Dim at As String, b As String, c As String, an As Integer at = "120" an = 2 b = "1" c = "3" ct = at < b 'false cn = an < b 'false kl = an < c 'true End Sub Case-2: Sub CompareNumberAndText() Dim at As String, b As String,

Categories : C#

How to increase the value of a specific array index of a dynamic array?
So… you want a dictionary with default values, then? Or something like this? Dictionary<char, int> frequencies = new Dictionary<char, int>(); foreach(char c in line) { if(frequencies.ContainsKey(c)) { frequencies[c]++; } else { frequencies.Add(c, 1); } }

Categories : C#

In VBscript, how do you set an array element to be a dynamic array?
Redim MasterArray(10) For x = 1 To 10 Redim SubArray(10) MasterArray(x) = SubArray Next MasterArray(1)(2) = 5 MasterArray(2)(2) = 6 MsgBox MasterArray(1)(2) ' shows 5 MsgBox MasterArray(2)(2) ' shows 6

Categories : Vbscript

Sorting events with dates in javascript object array and comparing with current date to display in a form
You need to change a few things. For starters you need to change the way you put the dates in the object, because you can not compare a date with that format. So change them to be `10/12/2013' (October 12, 2013). Second, you compare event[i] with today, but event[i] is the object so you need to do event[i].eventdate. function addFormField() { var event = [] event[0] = { name: "calendarevent1", eventdate: "10/12/2013" } event[1] = { name: "calendarevent2", eventdate: "11/2/2013" } event[2] = { name: "calendarevent1", eventdate: "12/20/2014" } var today = new Date(); event.sort(); var nextLater = null; for (var i = 0; i < event.length; i++) { if (new Date(event[i].eventdate) > toda

Categories : Javascript

Comparing class member array elements and main elements
Your canswers member is not a valid declaration. It is likely using an extension provided by your compiler to support the C flexible array member. This will act like a 0 sized array, and your access to the canswers variable are thus reading and writing beyond the object boundary, resultig in undefined behavior. You should either declare canswers with the right array size, or allow it to be a vector<char> or array<char, 20> instead. For vector<char>: class TestGrade { public: void setKey(char []); void grade(char []); std::vector<char> canswers; void display(); }; If you use vector<char>, you would need to change how you implement setKey(). void TestGrade::setKey(char answers[]) //setting values from "key" array in main { canswers.clear

Categories : C++

Build Curl on vc9/vc11 with release dynamic library with dynamic ssl, ssh2 and dynamic zlib
The answer is: you can't What you should do is build curl with ssl, ssh2 and zlib internally using CFG=release-ssl-ssh2-zlib. Then use this patch to add the dlls to the link command. Note this patch is for VC10, but can easily be done on the vc9 makefile. After the builds, you will need to add libssh2.lib in to lincurl.lib, if you want to build something against it (say PHP). That can be done with this command (set the paths to the your libssh2.lib and libcurl.lib): lib.exe /OUT:libcurl_merged.lib libssh2.lib libcurl.lib copy libcurl_merged.lib libcurl.lib

Categories : Windows

2d numpy.array() comparing one string to all others, and repeated for each string
Check out the itertools library. The product function seems to be what you are after In [19]: list( product([1, 2, 3, 4, 5], repeat=2) ) Out[19]: [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)]

Categories : Python

Dynamic Array in C
You are mixing terminologies. In C and C++ arrays are technically a sequence of contiguous elements of the same type. When using the term "dynamic array" you are not using a standard-mandated term, but a general computer science term, which refers to array-like containers whose size can change at runtime. In C++ these array-like containers are implemented, for example, through the vector class, available including the <vector> standard library header. In other languages there may be other facilities. C has no dynamic arrays, but you can allocate arrays dynamically. Here the term "dynamic" has a different meaning: it is related to the management of dynamic memory, which is what you do when you use malloc and free functions. In C++, dynamic arrays are implemented managing dynamic m

Categories : C



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.