If my question were stupid, forgive me. but please someone tell me or suggest me how to solve this problem. I actually have a large multidimensional array
like this
$array_value = Array
(
[0] => Array
(
[0] => sdfsf
[1] => fghbfh
[2] => sgddfsg
[3] => ujmnm
[4] => jkluik
..
..
..
..
..
..
[150] => jhbjhbjh
)
[1] => Array
(
[0] => 44062
[1] => 45503
[2] => 44062
[3] => fdg
[4] => dfgdg
..
..
..
..
..
..
[150] => jhbjhbjh
)
....
....
....
[590] => Array
(
[0] => 44062
[1] => 45503
[2] => 44062
[3] => fdg
[4] => dfgdg
..
..
..
..
..
..
[150] => jhbjhbjh
)
)
600 array of 600 array has 150 array values. When I use this array, if the foreach condition and the loop condition to complete the execution takes more than 5 minutes.
im using two foreach loops and one for the loop and 4 methods in the loop. It takes more than 5 minutes. I need to boot faster.
I do not know how to increase script execution time or how to process this array. please suggest or help me how to deal with this problem. Thanks.
foreach ($Final_Data as $line_no => $val) {
foreach($val as $col_name=> $col_value) {
if ($col_name === 'tid' || $col_name === 'pid' || $col_name === 'local_list_id')
{
if(empty($col_value)) {
$null_error[] = "empty value in ".$col_name;
}elseif( $col_value !== null && !is_numeric( $col_value) ) {
$where_Error[] ="non numeric value in ".$col_name." = ".$col_value;
}
$where_content[]= $col_name . "= '" . $col_value."'";
if($col_name =='pid'){
$pid = $col_value;
}
}elseif(!empty($col_name) && in_array($col_name, $update))
{
if($col_name=="country"){
...
}elseif($col_name=="state"){
...
}elseif($col_name=="district"){
....
}elseif($col_name=="post_category")
{
....
$CategoryList=array();
if(count($locationArr) > 0 && count(locationCategory($locationArr)) > 0)
{
.....
}
if(strlen($col_value)==0 || empty($col_value))
{
......
}elseif(ValidateLength($col_name,$columnValue,$maxl) === false || VulnerableExists($columnValue)===false)
{
if(ValidateLength($col_name, $columnValue,$maxl) === false){
....
}
if(VulnerableExists($columnValue)===false){
....
}
}else
{
......
foreach($post_cat as $Category){
if(get_cat_ID($Category) == 0) {
if(!in_array($Category, $CategoryList)){
.....
}
}
}
if(count($post_cat)>0 && isset($pid) && !empty($pid) && count($CategoryList)==0)
{
$postCat = array();
$ex_catid = array();
$post_categories = get_the_category( $pid );
foreach($post_categories as $category) {
if(in_array($category->name, $post_cat)){
.....
}
}
$array_dif = array_diff($post_cat,$postCat);
foreach($array_dif as $pc){
......
if($cat_Id!=0) array_push($ex_catid,$cat_Id);
}
if(count($array_dif)!=0){
......
}
}elseif(count($CategoryList)>0)
{
}
}
}
$columnName=$col_name;
$columnValue=mysqli_real_escape_string($link, $col_value);
if(ValidateLength($col_name,$col_value,$maxl)===false)
{
......
}elseif(VulnerableExists($col_value)===false)
{
......
}else
{
......
}
}
}
die();
if(!empty($val['pid']) && !empty($val['tid']) && !empty($val['local_list_id']) ) {
if(count($vuln_error) <= 0 && count($length_error)<=0 && count($null_error)<=0 && count($CategoryList)<=0){
....
}else
{
....
}
}
unset($where_content);
unset($update_content);
unset($null_error);
unset($vuln_error);
unset($length_error);
unset($CategoryList);
echo "<br><br>";
}
. script if forloop foreach. , . , . Thankyou
- 1000 1000 . 4 5 .