Tagged Questions
1
vote
2answers
40 views
Best way to check for one of two values in an array in PHP
I want to see if one of two values (a, b) are in an array. Here's my current thought:
$match_array = array('a','b');
$array_under_test = array('b', 'd', 'f');
if (array_intersect($match_array, ...
1
vote
1answer
39 views
Referring to nested arrays and array_merge (php)
In such an array:
$arr = Array (
[key0] => Array (
[subkey0] => Array (
[0] => "value0"
[1] => "value1"
)
[subkey1] => Array (
...
0
votes
1answer
53 views
Turning multiple PHP arrays into one array ready for conversion to Javascript
I am creating a multiple choice quiz game with PHP and Javascript. Questions can have 2 to 6 answers. I have been using the PHP queries in the code below to get arrays of the questions of a quiz, and ...
0
votes
2answers
44 views
Checking for array key exists in multi-dimensional array in PHP
Say I have a data structure like this:
array(3) {
["id"]=>
int(1)
["name"]=>
string(3) "foo"
["message"]=>
array(1) {
["action"]=>
string(3) "PUT"
}
}
Where ...
1
vote
1answer
55 views
PHP generic array group by using lambda
K.I.S.S
But how about some error and misuse control? I am wishing it were .NET HAHA.
<?php
function array_group_by($arr, $key_selector) {
$result = array();
foreach($arr as $i){
...
5
votes
2answers
100 views
Array find min value with user-defined comparison compare function
My user defined comparison compare function is defined with an array:
$boardkey_to_values=Array(19=>2601248,23=>2601248,39=>2603445,
...
1
vote
2answers
65 views
Looking For a More Efficient/Elegant Way To Write a MySQL Query
I'm querying a MySQL database and displaying the info in order of timestamp (DESC). Essentially, I'm grabbing the last record in the database, displaying it's date and year as the header of it's ...
3
votes
1answer
723 views
Better way of handling data returned from fetch_assoc() (mysqli)
So I connected to the db, pull the data using fetch_assoc() (fetch_all(NUMB) is not available on the machine we are working with else this would be less of an issue). So I get the returned data and ...
3
votes
1answer
103 views
Small class to manage config data
I made this small class the allows me to navigate large arrays using something like: key1/key2/key3
I made this because I was creating large arrays to hold my classes configs and needed a simpler way ...
1
vote
1answer
845 views
Routing in MVC with PHP
I am in the progress of creating a MVC structured website. I've opted to make my own instead of using pre-constructed MVC systems as a way to teach myself better coding and understand how applications ...
1
vote
1answer
125 views
Extracting Multiple Associative arrays in PHP
public static function find_user_tracks($id)
{
global $mySQL;
$sql = "SELECT * FROM `tracks` WHERE account_id = {$id}";
$result_set = $mySQL->query($sql);
$ret = array();
...
0
votes
1answer
118 views
What is wrong with these PHP arrays, is_array returns false and foreach says invalid [closed]
I have hit a brick wall in my project: PHP doesn't consider the $bon_v1 an array.
What is wrong with all of this/ some of this?
$bon_r1 = array(
"in" => "#pp1",
"ot" => "bon-r1",
"fn" => ...
1
vote
1answer
87 views
PHP illegal offset type in multiple loop structure
For reference, the function in question takes a URL structure which is most often a query string (but sometimes not) and generates filters to remove query var's from the URL. So if you're looking at ...
1
vote
1answer
783 views
PHP Add Column to two dimentional array
i do have two dimentional array of data in php.
I do want to add another column with constant to that array for passing tabular data to next program.
i am iterating and adding manually. What can ...
1
vote
2answers
722 views
Mutlilevel page list in CodeIgniter
I'm newly working with CodeIgniter and PHP. I wrote a category structured 'pages' code with listing pages as multilevel list or indented select box.
page ...