php - Pass array as var -
i have function using based on example @ https://wordpress.org/plugins/custom-list-table-example/
this sets array this...
var $example_data = array( array( 'id' => 1, 'title' => '300', 'rating' => 'r', 'director' => 'zach snyder' ), array( 'id' => 7, 'title' => 'watchmen', 'rating' => 'r', 'director' => 'zach snyder' ) );
i trying replace own function creates array this...
function create_array() { $count1 = $wpdb->get_results("select count(*) totalvaluecount, value thevalue, date(date_created) thedate wp_rg_lead inner join wp_rg_lead_detail on wp_rg_lead.id = wp_rg_lead_detail.lead_id wp_rg_lead.form_id = '47' , date_created between date_sub(now(), interval 7 day) , now() , field_number = '18' group thevalue, thedate"); $values = array(); foreach ($count1 $page) { $values = array_merge($values, array(array( 'rep' => $page->thevalue, $page->thedate => $page->totalvaluecount, ))); } function in_array_r($needle, $haystack, $strict = false) { foreach ($haystack $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { return true; } } return false; } $codes = array(); $counter = -1; foreach($values $key => $value) { if(!in_array_r($values[$key]["rep"], $codes, true)) { $codes[++$counter] = array(); foreach($values[$key] $subkey => $subvalue) { $codes[$counter][$subkey] = $subvalue; } } else { foreach($values[$key] $subkey => $subvalue) { if($subkey != "rep" && $subkey != "id") { $codes[$counter][$subkey] = $subvalue; } } } } }
how can modify function pass array in same way original?
Comments
Post a Comment