I am having issue with number formatting of array elements. It always returns an “A” letter, no matter element value. I am calling for that value with adress $tab[‘VII’][‘B’][‘podatek’][‘PTUG’] An this is part of an Array: I am using tcpdf with this …
Tag: arrays
Promises in array forEach loop
I have an array like this: var ids = [8372839402, 8392615782, 3677281302]; Inserted are id values. Based on this ids I have to get for each one some information from the database. Basicly I get data …
Combine object values in a single array by matching object fields in PHP
I’ve been digging around and trying to solve this issue the cleanest way possible, but haven’t quite found the right approach. I have an array of objects like so: and I need to combine the objects that have duplicate measurement fields and combine the counts like this: can it be done with somethin…
Searching element in multidimensional array – using recursion
I want to write own searching function in multilevel array using recursion. Results are incorrect for last 2 elements 111, 12. I get NULL. For the rest it’s ok. What is wrong? Answer
Recursive function and add to an array
I need recursive function to add element into an array. This is my code: Basically, if I echo $new_x and $new_y, I get what I’m expecting. Problem is my $result array, it gives me only first item (2 -2) but second is missing (1 -1). I guess problem is with adding item into array but cannot find the prob…
unserialize() expects parameter 1 to be string, array given
I am storing data in mysql table by serialize method, now I want to print all data So I wrote mysql query and trying to unserialize because data is in serialize format but unserialize showing error. Error: Query to fetch all records Answer Your $result variable contains a multi-dimensional array. Assuming tha…
How to Combine 2 Array with same key
I have 2 array like this … $a = [ [“Name” => “DH”, “TotalSel” => 11700.0], [“Name” => “PD”, “TotalSel” => 7000.0], [&…
Looping from an array display a non wanted character with PHP
I have this array in PHP: I want to loop into the color array like this: The problem, is the first result is b from block. How can I change this behavior ? Thanks. Answer You can check whether the name element exists in the $color value:
PHP: Adapt number ID to words
What do I need to do to convert the number only if all the number matches? At the moment, it’s converting to each number. (I’ve tried to do a lot and I didn’t succeed) I would like to know if have any way of adapting to only show the word if the number “is complete”, otherwise sh…
Shuffle() returns same results
I’m having a problem with using a basic shuffle() function in Laravel. It returns the same result, which seems to be changing once every 10 or 20 minutes. Here’s the basic code I’m testing: And here’s the log: Answer You probably initialize your random seed with a constant value somewh…