All Questions
72,473 questions
1
vote
1
answer
20
views
How do you return a more complex data type in PHP / nusoap?
I am using PHP / nusoap to build an API and have seen a number of ways to return complex data types. These generally refer to either a mixed data type or an array. An example is returning:
$aInvoice =
...
-2
votes
0
answers
37
views
How to have the sum of the values of each matching key across all sub-arrays in php [duplicate]
I have an array of associative arrays. I want to write a function to return a new array that has the sum of the values of each key in the associative arrays
$data = array(
array(
"...
1
vote
1
answer
68
views
How do I send a http post request with an array as a post parameter in laravel
I am trying to send a post request in laravel. Below is my code:
$response = Http::withToken($local_signature)
->post('myUrl', [
"amount" => $amount,
"...
0
votes
0
answers
36
views
PHP array_combine adds a new line breaking the script [duplicate]
I used the following array which works
$header_list = [
"Symbol",
"Description",
"Qty",
"Price Per Share",
...
0
votes
0
answers
50
views
How can I count how many times multiple items show up in a database? [duplicate]
I would like to count each multiple of the items in an array returned from a SQL query:
$results = $stmt->fetchALL(PDO::FETCH_ASSOC);.
So if there are 5 instances of John and 3 of Sue in the db, ...
-5
votes
2
answers
65
views
Is there a more efficient way to extract links from an array of strings?
I run (Real Estate RETS) queries that will only return objects. The contents of these objects appear to be strings that contain different types of information about sets of images (ie. several ...
4
votes
5
answers
172
views
Check if a string starts with a substring from an array of substrings and return that substring
I have an array with all German telephone area codes that is 5266 items long and looks like this:
$area_codes = array(
'015019',
'015020',
'01511',
'01512',
'01514',
'01515',
...
0
votes
1
answer
52
views
Translate and combine a PHP string array using Smarty
I'm working on come code that uses Smarty for templating. I have a php function that creates an array of strings, and this function is called from a Smarty { } block. Within that Smarty block I need ...
0
votes
0
answers
30
views
How to generate Nested JSON using PDO [duplicate]
I took note of this question Nested JSON using Python, but I was not quite satisfied with the answers provided because I thought that
it could be better to do this with results of a database, and let ...
0
votes
1
answer
60
views
Combine row number in a multi-dimensional array and value from subordinate array into a new array faster than with a loop [duplicate]
I have a two-dimensional array that looks something like this:
Array
(
[0] => Array
(
[0] => 1
[1] => John
[2] => Smith
[3] =>...
0
votes
0
answers
18
views
PHP Warning: Trying to access array offset on null [duplicate]
I'm getting this PHP error after a server move, can anyone suggest a solution?
PHP Warning: Trying to access array offset on null in /public_html/cpd-online/wp-content/plugins/sfwd-lms/includes/...
0
votes
3
answers
138
views
Fastest way to randomly shuffle an array based on probabilities in PHP? [closed]
I have an array with values and probabilities (or in PHP, keys and values):
Value Probability
John 3
Peter 2
Paul 1
I want to shuffle this array but have the order be influenced by the ...
-2
votes
3
answers
137
views
Parse a CSV file which may have columns out of the expected order
I use the fgetcsv() function to break a .CSV file into an array so I can insert the values into a database.
The problem is that sometimes the corporation that I download these files from change ...
1
vote
1
answer
35
views
Copy first level keys of a 2d array as a new column of each row
Assuming a 2d array as input, how can each first level key be copied as a new element in its second level row?
Sample input:
$members = [
'myname' => ['userid' => 52, 'age' => 46],
'...
2
votes
1
answer
53
views
PHP Search and Insert Matching Term on Multidimensional Array
I've been working on a revision to a hierarchical search and now have to go down more than 3 levels. Issue is I'm having to convert a single level array to a multi-level. I've attempted to use ...