Little brother in WordPress wrote a program, the approximate process is as follows:
1, $get _posts_array call a category of articles
$get _posts_array = query_posts (Array (' posts_per_page ' = = $numberposts, ' by ' = ' = ' $orderby ', ' category__and ' = >array ($sub _cat_id_str)));
2. Loop to find all the pictures in the article
foreach ($posts _array as $index = + $post _value_array) {if ($post _value_array->post_status = = ' publish ') {Ob_start ( ); Ob_end_clean ();p reg_match_all ('//i ', $post _value_array->post_content, $pic _rexz); $post _item_array= $post _value _array->id. ' # '. $post _value_array->post_title. ' # '. $post _value_array->post_name. ' html# '. $post _value_array->guid. ' # '; if (!empty ($pic _rexz[1]) {$posts _pic_array[$index] = Array_merge ($pic _rexz[1], (array) $post _item_array);}}}
3. When using a foreach or if statement to output an array $posts_pic_array, the problem occurs as follows:
1, in the XAMPP environment of this machine, output array with foreach or if statement $posts _pic_array are normal;
2, uploaded to the server windows on IIS + PHP5.4 environment, in the article classification id=1, the loop output $posts _pic_array array, can only print 3 data. (The Ps:count ($posts _pic_array) array is 150 records). Why other classifications are normal, other categories of $posts_pic_array Records also have 50-100 different Ah! Either the foreach or if statements have been tested, and only 3 records can be output.
Commissioning for 2 days, I hope you can help!
Reply to discussion (solution)
On-line reply, solve!
if ($post _value_array->post_status = = ' publish ')
Is that the decision to filter out?
if ($post _value_array->post_status = = ' publish ')
Is that the decision to filter out?
Tested, not related to this, when the classification of id=1, COUNT ($posts _pic_array) Statistics There are 150, with the print command can also print the array, but with a foreach or for loop, can only loop out 3, And, oddly enough, the statement after the foreach statement is not executed. is not a memory overflow and other problems Ah!
Problem, find it! Really is a memory overflow problem, a unset statement actually can let 128M of php.ini configuration overflow! Just tested, delete the unset statement is normal!