doddsey_65 Posted February 20, 2011 Share Posted February 20, 2011 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 More sharing options...
doddsey_65 Posted February 20, 2011 Author Share Posted February 20, 2011 used: [color=black]$bb[$i] = "#\[attachment=(.*?)\]#si"; $html[$i] = $description;[/color] and it works. Link to comment https://forums.phpfreaks.com/topic/228273-variable-problems/#findComment-1177108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.