Convert byte array to string in PHP

Being new to PHP I need to convert an array of bytes to a string that may be used in php function; hash_hmac("sha256", $payload, $key, true) The $key will originate from a Guid, say {6fccde28-de32-4c0d-a642-7f0c601d1776}, that's converted to an arra...
more »

2017-07-19 09:07 (2) Answers

Find a sequence of integers in a given array

I would like to know if there is a better way (in the case my implementation is correct) to find a sub-sequence of integers in a given array. I have implemented the solution using golang (if this is an impediment for a review I could use a different ...
more »

2017-07-19 06:07 (2) Answers

elm decode non-uniform array

I need to decode a JSON array where the head item is of type User and all the tail items are Nickname's. The array length is not known beforehand and I cannot change the JSON representation. JSON sample: { "userdata" : [ { "id" : 1, ...
more »

2017-07-19 00:07 (1) Answers

How do I find the largest number in an array?

I am trying to find the biggest number in an array and the corresponding position. For example if the array was {0,1,5,4,2,9} the solution would be 9 and the corresponding position would be 5. My current solution is for (int m=0; m<=Storage...
more »

2017-07-18 23:07 (0) Answers

Eliminating null value nested array php

I have an array and contents nested inside the original array. The contents of the array look like- $myArray [0] => Array( [ID] => 1 [Fruit] => Apple [State] => Ohio [description] Array( [0] => This is sample description ...
more »

2017-07-18 14:07 (1) Answers

Initialize transposed numpy array

I want to use the Singular-Value-Decomposition of matrix A. If possible I would write: V, S, W.T = np.linalg.svd(A) But I can't initialise an array with its transposed. Now I have two questions: As far as I understand the python internals ther...
more »

2017-07-18 14:07 (1) Answers

Merging 3 arrays in PHP

I have 3 arrays as below. $array1 = Array ( [0] => 05/01 [1] => 05/02 ) $array2 =Array ( [0] => ED [1] => P ) $array3 =Array ( [0] => Mon [1] => Tue ) I want to merge these 3 arrays as below $result_arr...
more »

2017-07-18 13:07 (6) Answers

Sum of the previous elements in an array

I have a array [3.0, 3.0, 2.0, 5.0, 6.0, 10.0] For each element of the array, I need the sum of its previous elements. I know how get the previous element but not all the previous elements. last = mytab[index - 1] //change here res = (e + last)...
more »

2017-07-18 12:07 (3) Answers

JavaScript : Sorting an array

Unsorted array [input] : ["> 30 days", "< 7 days", "< 30 days", "< 10 days"]; The format of an elements in array will always be like : </> X days Requirement : Above mentioned array should be sorted as per the greater then (>...
more »

2017-07-18 11:07 (3) Answers

Finding a true integer square root from an array

I'm sure this is such a simple solution and for that I'm sorry but it's driving me mad. I'm trying to iterate over an array and find a true integer square root and if there isn't one then square the number instead. I don't know how to do Math.sqrt...
more »

2017-07-16 21:07 (5) Answers

How to get an array instead of json object?

<?php $link = mysql_connect('localhost', 'root', 'admin') or die('There was a problem connecting to the database.'); mysql_select_db('hospitalmaster'); $hnum = (int)$_POST["hnum"]; $sql = "SELECT d.doctorid, d.doctorname from hospitalm...
more »

2017-07-16 18:07 (1) Answers

How to remove empty node in JsonNode

i have some json, like this: String str = "{\"menu\":[{\"form1\":\"nameForm1\"}, {\"form2\":\"nameForm2\"}]}"; ObjectMapper objectMapper = new ObjectMapper(); JsonNode testNode = objectMapper.readTree(str); After some actions, I modified my json. ...
more »

2017-07-16 13:07 (1) Answers

Run a Node endpoint for every item in array?

I am using ExpressJs, NodeJs, AngularJs. Let's say I have an array with several objects that represent grocery store accounts and the amount owed to them by the bank. [{ account: 1, amount: 2.33 }, { account: 2, amount: 5.99 }, { account: 3, ...
more »

2017-07-16 00:07 (1) Answers