I have some multimple issues whit this but I never get a good andword about it.
I have some function who respond good but the problmes is is printing x2 my query.
I try to minimize my script to get help fast.
The is about array_merge.
So first
- Verify Function
function Verify($params) {
$query = mysql_query("SELECT SOMETHING");
if ($query->num_rows > 0) {
$row = $query->fetch_assoc();
// Here will pass 2 array on each function to proceed
$data = self::CacheData($row['gid'], $params['sid']);
$data['data'] = self::Host($row['gid'], $params['sid']);
return $tmpdata;
}
return false;
}
- Create ChacheData and Host Function.
static function CacheData($gid, $sid){
$cachedata = array();
$querycache = mysql_query("SELECT WHAT I NEED");
if ($querycache->num_rows == 1) {
$rowcache = $querycache->fetch_assoc();
// Send to Files the array and check if is true
if (self::Files(array('gid' => $gid, 'sid' => $sid, 'expirecache' => 0)) == true) {
return array('gid' => $gid, 'size' => 0, 'enabled' => $rowcache['enabled'], 'exists' => false);
}
}
}
function Host($gid, $sid) {
$query = mysq_query("SELECT WHAT I NEED");
if ($query->num_rows == 0) {
return false;
}
$rowgame = $query->fetch_assoc();
// Send to Files the array and to see if is / false
if (self::Files(array('gid' => $gid, 'sid' => $sid)) == false) {
return false;
}
}
Ok here is the issues I have
When the Files recive the 2 array it`s working perect but I whant all array send by other function to array_merge all.
So the last function where is the issues is like this
function Files(array $params) {
$default = array('skipcache' => false, 'expirecache' => 86400, 'os' => null);
$params = array_merge($default, $params);
//return $params;
print_r($params);
}
Now The Output will be like
array(5) {
["skipcache"]=>
bool(false)
["expirecache"]=>
string(1) "0"
["os"]=>
NULL
["gid"]=>
string(1) "1"
["sid"]=>
string(1) "1"
}
array(5) {
["skipcache"]=>
bool(false)
["expirecache"]=>
int(86400)
["os"]=>
NULL
["gid"]=>
string(1) "2"
["sid"]=>
string(1) "1"
}
Base on this output I add on Database but the problmes is is add 2 on database and I need 1 array not 2.
So I was see the array_merge remove dublicates but here I see all it`s same but Is not remove because $params recive 2 array !
Can you give me some solution but not whit Foreach !
Thank you so much !
Regards,