[Solved] C# array string names change content order

First, let’s elaborate rules: One part “John” -> “John” (do nothing) Two parts “John Smith” -> “Smith, John” (last, first) Three+ parts “John Peter Jack Smith” -> “Smith, John P. J.” (last, first, other in order as single letters) Having these rules we can implement a simple reordering: private static String ReOrderNamesParts(string name) { if … Read more

[Solved] In char x[10]=”hello” , why cout

It prints “Hello” because operator << has an overload for const char* (which is what you’re passing if you pass x) that prints out a single char and moves to the next char until a NUL-character is found. “Hello” has a compiled-added NUL-character at the end, so your string is actually “Hello\0”. To get the … Read more

[Solved] JSON Object to Jquery select array [closed]

You can use Array.prototype.map() function. var o = {“tuple”:[{“old”:{“MST_VAS_TYPE”:{“MST_VAS_TYPE_ID”:”VAS_1000″,”VAS_TYPE_NAME”:”AMC”,”VAS_TYPE_DESC”:”Annual Maintenance Contract”,”CREATED_ON”:null,”CREATED_BY”:null,”MODIFIED_ON”:null,”MODIFIED_BY”:null,”@xmlns”:”http://services.vw.com/lpms/1.0/wsapp”}},”@xmlns”:”http://services.vw.com/lpms/1.0/wsapp”},{“old”:{“MST_VAS_TYPE”:{“MST_VAS_TYPE_ID”:”VAS_1001″,”VAS_TYPE_NAME”:”EW”,”VAS_TYPE_DESC”:”Extended Warranty”,”CREATED_ON”:null,”CREATED_BY”:null,”MODIFIED_ON”:null,”MODIFIED_BY”:null,”@xmlns”:”http://services.vw.com/lpms/1.0/wsapp”}},”@xmlns”:”http://services.vw.com/lpms/1.0/wsapp”},{“old”:{“MST_VAS_TYPE”:{“MST_VAS_TYPE_ID”:”VAS_1002″,”VAS_TYPE_NAME”:”COUPON”,”VAS_TYPE_DESC”:”Recall”,”CREATED_ON”:null,”CREATED_BY”:null,”MODIFIED_ON”:null,”MODIFIED_BY”:null,”@xmlns”:”http://services.vw.com/lpms/1.0/wsapp”}},”@xmlns”:”http://services.vw.com/lpms/1.0/wsapp”}],”@xmlns:SOAP”:”http://schemas.xmlsoap.org/soap/envelope/”,”@xmlns”:”http://services.vw.com/lpms/1.0/wsapp”}; a= o.tuple.map(function(val){ var inner = val[‘old’][‘MST_VAS_TYPE’]; var ret = {}; ret[inner[“MST_VAS_TYPE_ID”]] = inner[‘VAS_TYPE_NAME’]; return ret; }) sel = document.createElement(“select”); document.body.appendChild(sel); for (var index in a) { obj = a[index]; for (var prop in obj){ option = document.createElement(“option”); option.text = obj[prop]; option.value = prop; … Read more

[Solved] How to group the second elements of multiple nested arrays based on first element in javascript? [closed]

You can reduce your array to produce the desired result like this let firstArray = [[0,2], [1,3], [0,5], [2,8], [1,4], [4,2]]; const secondArray = firstArray.reduce((acc, [ idx, val ]) => { acc[idx] = acc[idx] ?? [] // initialise to an empty array acc[idx].push(val) // add the value return acc }, []).filter(Boolean) // filter skipped indices … Read more

[Solved] Multiple array keys from array

$array = array(); $current =& $array; $keys = $array(‘one’, ‘two’, ‘three’); $value=”text”; foreach (array_slice($keys, 0, -1) as $k) { $current[$k] = array(); $current = & $current[$k]; } $current[$keys[count($keys)-1]] = $value; Using a reference for $current allows it modify the nested arrays in place. 1 solved Multiple array keys from array

[Solved] PHP: Show the difference in two arrays when elements out of order

You can use array_diff_assoc() to do this, it works out the difference between the two arrays, with a key check to verify that the keys are the same as well: $a = [‘id’, ‘name’, ‘age’, ‘gender’]; $b = [‘id’, ‘age’, ‘name’, ‘gender’]; $expected = array_diff_assoc($a, $b); $actual = array_diff_assoc($b, $a); echo ‘Expected = ‘, implode(‘, … Read more