Jump to content

[SOLVED] str_replace on IF statement


kyleldi

Recommended Posts

I've got an if statement that I need to replace some characters on before it outputs to the browser, (spaces converted to +), but when I do it, it doesn't output correctly.  Any idea where i'm going wrong?

 

do {
echo '<div class="thumbframe">'.$row_rs_multi_cats['category'] = str_replace(" ","+",$row_rs_multi_cats['category']).'
<div class="thumb"><a href="downloads.php?category='.$row_rs_multi_cats['category'].'"><img src="images/downloads/'.$row_rs_multi_cats['category'].'.jpg" alt="'.$row_rs_multi_cats['category'].'" width="100" height="58" border="0" longdesc="downloads.php?category='.$row_rs_multi_cats['category'].'" /></a></div> 
<div>'.ucwords($row_rs_multi_cats['category']).'</div></div>';
   } 
   while ($row_rs_multi_cats = mysql_fetch_assoc($rs_multi_cats)); 
}

Link to comment
https://forums.phpfreaks.com/topic/149225-solved-str_replace-on-if-statement/
Share on other sites

 

 

 

do {

echo '<div class="thumbframe">'.str_replace(" ","+",$row_rs_multi_cats['category']).'

<div class="thumb"><a href="downloads.php?category='.$row_rs_multi_cats['category'].'"><img src="images/downloads/'.$row_rs_multi_cats['category'].'.jpg" alt="'.$row_rs_multi_cats['category'].'" width="100" height="58" border="0" longdesc="downloads.php?category='.$row_rs_multi_cats['category'].'" /></a></div>

<div>'.ucwords($row_rs_multi_cats['category']).'</div></div>';

  }

  while ($row_rs_multi_cats = mysql_fetch_assoc($rs_multi_cats));

}

 

Regards

Hastimal Shah

Hi see check this code its working

copy this code in new file and run and check the output

 

<?php

$row_rs_multi_cats = array('category'=>"hello world");

echo '<div class="thumbframe">'.$row_rs_multi_cats['category'] = str_replace(" ","+",$row_rs_multi_cats['category']).'
<div class="thumb"><a href="downloads.php?category='.$row_rs_multi_cats['category'].'"><img src="images/downloads/'.$row_rs_multi_cats['category'].'.jpg" alt="'.$row_rs_multi_cats['category'].'" width="100" height="58" border="0" longdesc="downloads.php?category='.$row_rs_multi_cats['category'].'" /></a></div>
<div>'.ucwords($row_rs_multi_cats['category']).'</div></div>';
  

?>

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.