עזרה

bnayal

New member
עזרה

1. אני מחפש קוד שיוסיף לי טקסט לתוך תיבת טקסט למשל: כמו הסמיילים בפורומים. 2. קוד php שיבדוק אם בתוך תיבת טקסט קיים טקסט מסויים ואם כן יחליף אותו לטקסט אחר. ניסיתי ככה:
replace("bbb", "aaaa");​
ולא עבד
 

bnayal

New member
למה זה לא עובד?

$pieces[3] = str_replace("", "<b>"); $pieces[3] = str_replace("", "</b>");​
 

bnayal

New member
לא עובד - הקוד המלא:

<body bgcolor="#d5d5d5"> <?PHP $data = file('news.txt'); $data = array_reverse($data); foreach($data as $element) { $element = trim($element); $pieces = explode("|", $element); echo '<center><table width="500" height="106" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr> <td width="914" bgcolor="#FFFFFF"><div align="right"> <p><font color="#000000" size="+2"><strong>' . $pieces[1] . '</strong></font> </p> <p><font size="+1">' . $pieces[3] . '</font> </p> <p>הודבק על ידי ' . $pieces[2] . ' בתאריך ' . $pieces[0] . ' </p> </div></td> <td width="68" bgcolor="#FFFFFF" bordercolor="#FFFFFF"><img src="new.gif" width="60" height="60"></td> </tr> </table> <br></center>' ; } $pieces[3] = str_replace("", "<b>",$pieces[3]); $pieces[3] = str_replace("", "</b>",$pieces[3]); ?> </body> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1255"> <meta http-equiv="expires" content="no-cache"> </head>​
 

orenphp

New member
נו ברור...

אתה מדפיס למסך את המשתנה לפני שאתה משנה בו את מה שאתה רוצה?? קודם תריץ את הstr_replace ורק אח"כ תדפיס את זה למסך אם לא הבנת.
 
למעלה