Jump to content

variable problems


doddsey_65

Recommended Posts

for some reason $description is just showing the first result in the preg_replace function but when i echo it outside the function it shows all 3.

 

if(!empty($post_info[$key]['p_attachments']))
        {
            $attachment_list = explode('|', $post_info[$key]['p_attachments']);
            $a_list = '';
            $p_content = str_replace('<br>', '', $post_info[$key]['p_content']);
            
            $amount = count($attachment_list);
            
            for($i=0; $i<$amount-1; $i++)
            {
                $query = $link->query("SELECT a_name, a_description, a_size
                                        FROM ".TBL_PREFIX."post_attachments
                                        WHERE a_name = '".$attachment_list[$i]."'")
                                    or die(print_link_error());
                                    
                $result = $query->fetchAll();
                
                foreach($result as $k => $v)
                {
                    $description = $result[$k]['a_description'];
                }
                
                    
                    $bb[] = "#\[attachment=(.*?)\]#si";
                    $html[] = $description; // this just shows the first result 3 times
                echo $description; // but this shows all of the 3 results
                
                $p_content = preg_replace($bb, $html, $p_content); 
            }
        }

 

is this something todo with preg_replace?

Link to comment
https://forums.phpfreaks.com/topic/228273-variable-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.