[SOLVED] Extract array from another array
Posted: Wed Jul 30, 2008 10:35 am
I made two php classes that work with the database: the first would connect to the database and perform the queries, the second one would display the results or process and send data to be introduced in the database. Since these databases don' t follow any pattern or MVC and contain a lot of redundant code, the second class, I made a new function that wraps the resulting array in other array.
The result is a array in an array.
The problem is that I don' t know I way to extract in a fast manner the original array from the wrapper. I tried using extract, array_walk, foreach but I got only errors or nothing was being shown.
Any ideas?
My mistake: I didn' t put the exact name and order for the array. Thanks Kendal!
Code: Select all
class DisplayResults extends MySQLiResult{
function Generalization($ident,$query){
$wrap=array();
$result=array();
$temp="";
//initialise the first class
$dataB=new PMExtender($ident['server'], $ident['DataBase'], $ident['User'], $ident['pass']);
//QueryExec is a function that returns a MySQLi object
$result=$dataB->QueryExec($query);
while($temp=$dataB->fetch_assoc()){$wrap[]=$temp;}
}
}
The result is a array in an array.
Code: Select all
//an example of print_r($wrap);
wrap=[0=>Array[
"Title"=>"Test first query",
"Text"=>"Sample text for the tests involving this database"
]
1=>Array[
"Title"=>"Welcome to the site",
"Text"=>"This is my first post on these site..."
]
]
//I hope you got the idea
Any ideas?
My mistake: I didn' t put the exact name and order for the array. Thanks Kendal!