147
votes
5answers
89k views
Sort multidimensional Array by Value (2) [duplicate]
Possible Duplicate:
How do I sort a multidimensional array in php
How can I sort this array by the value of the "order" key? Even though the values are currently sequential, they will not ...
124
votes
10answers
23k views
PHP PDO: Can I bind an array to an IN() condition?
I'm curious to know if it's possible to bind an array of values to a placeholder using PDO. The use case here is attempting to pass an array of values for use with an IN() condition.
I'm not very ...
28
votes
10answers
17k views
How to Flatten a Multidimensional Array?
Is it possible, in PHP, to flatten a (bi/multi)dimensional array without using recursion or references?
I'm only interested in the values so the keys can be ignored, I'm thinking in the lines of ...
295
votes
9answers
288k views
How to delete an element from an array in php?
Does anyone know an easy way to delete an element from a php array? So that foreach($array) no longer includes that element. I thought that setting it to null would do it, but apparently not.
21
votes
5answers
21k views
Sorting an associative array in PHP
I have an array in this format:
Array
(
[0] => Array
(
[text] => tests
[language] =>
[advertiserCompetitionScale] => 5
...
72
votes
19answers
77k views
42
votes
13answers
82k views
How to search by key=>value in a multidimensional array in PHP
Is there any fast way to get all subarrays where a key value pair was found in a multidimensional array? I can't say how deep the array will be.
Simple example array:
$arr = array(0 => ...
11
votes
22answers
3k views
PHP syntax for dereferencing function result
In every other programming language I use on a regular basis, it is simple to operate on the return value of a function without declaring a new variable to hold the function result.
In PHP, however, ...
29
votes
6answers
25k views
How to remove duplicate values from a multi-dimensional array in PHP
How can I remove duplicate values from a multi-dimensional array in PHP?
Example array:
Array
(
[0] => Array
(
[0] => abc
[1] => def
)
[1] => Array
(
[0] => ...
15
votes
12answers
23k views
How to “flatten” a multi-dimensional array to simple one in PHP?
It's probably beginner question but I'm going through documentation for longer time already and I can't find any solution. I thought I could use implode for each dimension and then put those strings ...
172
votes
14answers
47k views
Preferred method to store PHP arrays (json_encode vs serialize)
I need to store a multi-dimensional associative array of data in a flat file for caching purposes. I might occasionally come across the need to convert it to JSON for use in my web app but the vast ...
62
votes
6answers
105k views
PHP/MYSQL using an array in WHERE clause
given an array
$galleries = array
(
[0] => 1
[1] => 2
[2] => 5
)
I want to have a sql query that uses the values of the array in its ...
20
votes
4answers
10k views
Transposing multidimensional arrays in PHP
How would you flip 90 degrees (transpose) a multidimensional array in PHP? For example:
// Start with this array
$foo = array(
'a' => array(
1 => 'a1',
2 => 'a2',
3 ...
2
votes
3answers
1k views
Sorting a multidimensional array in PHP?
I have this kind of an array
array(5) {
[0]=>
array(5) {
[0]=>
string(7) "jannala"
[1]=>
string(10) "2009-11-16"
[2]=>
string(29) "
<p>Jotain ...
44
votes
7answers
12k views
+ operator for array in PHP?
$test = array('hi');
$test += array('test','oh');
var_dump($test);
What does + mean for array in PHP?