Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.