cordoprod Posted July 14, 2008 Share Posted July 14, 2008 Hello.. Can somebody tell me why this code does not replace... function callback($buffer) { $array = array("æ", "æ", "Æ", "Æ", "ø", "ø", "Ø", "Ø", "å", "å", "Å", "Å"); foreach($array as $key => $value) { $return = str_replace($key, $value, $buffer); } return ($return); } ob_start("callback"); Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/ Share on other sites More sharing options...
rhodesa Posted July 14, 2008 Share Posted July 14, 2008 try: function callback($buffer) { $array = array( "æ" => "æ", "Æ" => "Æ", "ø" => "ø", "Ø" => "Ø", "å" => "å", "Å" => "Å", ); return str_replace(array_keys($array),array_values($array),$buffer); } Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589810 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 Hmm.. still doesn't work Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589815 Share on other sites More sharing options...
rhodesa Posted July 14, 2008 Share Posted July 14, 2008 worked fine for me: <?php function callback($buffer) { $array = array( "æ" => "æ", "Æ" => "Æ", "ø" => "ø", "Ø" => "Ø", "å" => "å", "Å" => "Å", ); return str_replace(array_keys($array),array_values($array),$buffer); } ob_start("callback"); ?> æ Lorem ipsum ÆNullam posuereøFusce et urna. åNam condimeÅiquam quis est. <?php ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589819 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 I can see them fine in ff and opera.. though it does not replace the source.. Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589821 Share on other sites More sharing options...
rhodesa Posted July 14, 2008 Share Posted July 14, 2008 when i load the code i posted, and do View Source...i get the following: æ Lorem ipsum ÆNullam posuereøFusce et urna. åNam condimeÅiquam quis est. do you not?? Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589828 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 when i load the code i posted, and do View Source...i get the following: æ Lorem ipsum ÆNullam posuereøFusce et urna. åNam condimeÅiquam quis est. do you not?? correct.. i don't Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589852 Share on other sites More sharing options...
rhodesa Posted July 14, 2008 Share Posted July 14, 2008 um...impossible? what is the output when you run this code: <?php $count = 0; function callback($buffer) { global $count; $array = array( "æ" => "æ", "Æ" => "Æ", "ø" => "ø", "Ø" => "Ø", "å" => "å", "Å" => "Å", ); $c = 0; $rval = str_replace(array_keys($array),array_values($array),$buffer,$c); $count += $c; return $rval; } ob_start("callback"); ?> æ Lorem ipsum ÆNullam posuereøFusce et urna. åNam condimeÅiquam quis est.<br> <?php ob_end_flush(); print "Made $count replacements"; ?> Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589861 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 um...impossible? what is the output when you run this code: <?php $count = 0; function callback($buffer) { global $count; $array = array( "æ" => "æ", "Æ" => "Æ", "ø" => "ø", "Ø" => "Ø", "å" => "å", "Å" => "Å", ); $c = 0; $rval = str_replace(array_keys($array),array_values($array),$buffer,$c); $count += $c; return $rval; } ob_start("callback"); ?> æ Lorem ipsum ÆNullam posuereøFusce et urna. åNam condimeÅiquam quis est.<br> <?php ob_end_flush(); print "Made $count replacements"; ?> Nothing.. no output Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589899 Share on other sites More sharing options...
rhodesa Posted July 14, 2008 Share Posted July 14, 2008 well, all i can say is make sure your PHP is configured correctly and make sure error reporting is turned on ...you can also try a simpler version of the code: <?php $count = 0; function callback($buffer) { global $count; $array = array( 'a' => 'AA', 'l' => 'LL', ); $c = 0; $rval = str_replace(array_keys($array),array_values($array),$buffer,$c); $count += $c; return $rval; } ob_start("callback"); ?> Lorem ipsum nullam posuere fusce et urna. Nam condime iquam quis est. <?php ob_end_flush(); print "<br>Made $count replacements"; ?> Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589936 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 It's configured.. but i have one to make the header() work two lines above.. does that affect anything? Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589941 Share on other sites More sharing options...
rhodesa Posted July 14, 2008 Share Posted July 14, 2008 can you post all the code? Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589956 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 can you post all the code? Sure, but its a big page though.. <?PHP ob_start(); session_start(); $count = 0; function callback($buffer) { global $count; $array = array( "æ" => "æ", "Æ" => "Æ", "ø" => "ø", "Ø" => "Ø", "å" => "å", "Å" => "Å", ); $c = 0; $rval = str_replace(array_keys($array),array_values($array),$buffer,$c); $count += $c; return $rval; } ob_start("callback"); if(session_is_registered("username") && session_is_registered ("password")) $logged_in = true; else $logged_in = false; require_once('connect.php'); require_once('inc/functions.php'); require_once('inc/msn.class.php'); if($logged_in) UpdateActivity($_SESSION['username']); if($_GET['nick'] == "") $_GET['nick'] = $_SESSION['username']; if($_GET['s'] == "user") { $db = new DbConnector(); $db->connect(); $sql = "SELECT * FROM travek_usersettings WHERE nick='".$_GET['nick']."'"; $result = $db->query($sql); $num = mysql_num_rows($result); $fetch = $db->fetchArray($result); if($num != 0) { $textcolor = $fetch['textcolor']; $bgcolor = $fetch['bgcolor']; $texture = $fetch['texture']; if($bgcolor == "") $bgcolor = "#FFFFFF"; if($texture == "") $use_texture = false; else $use_texture = true; } else { $textcolor = "#666666"; $bgcolor = "#FFFFFF"; $texture = ""; } } if($bgcolor == "") $bgcolor = "#FFFFFF"; if($textcolor == "") $textcolor = "#666666"; $tab = 0; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=text/html;charset=utf-8" /> <title>Teenchill<? if(isset($_GET['nick'])) { echo ": {$_GET['nick']}"; }?></title> <link href="static/css/default.css" rel="stylesheet" type="text/css" /> <link href="js/solidblocksmenu.css" rel="stylesheet" type="text/css" /> <script src="js/ddtabmenu.js" language="javascript" type="text/javascript"></script> <script src="js/functions.js" language="javascript" type="text/javascript"></script> <script language="JavaScript1.1" type="text/JavaScript"> <!-- if (parent.frames.length > 0) top.location.replace(document.location); //--> </script> <link rel="shortcut icon" href="favicon.ico" > </head> <body> <script type="text/javascript" src="js/wz_tooltip.js"></script> <table width="998" height="1365" border="0" align="center" cellpadding="0" cellspacing="0" id="main_tbl"> <tr> <td colspan="2"><table width="100%" border="0" align="center" cellpadding="4" cellspacing="0"> <tr> <td><center> <img src="static/img/annonse.jpg" width="150" height="100" /> </center> </td> <td><center> <img src="static/img/annonse.jpg" alt="" width="150" height="100" /> </center> </td> <td><center> <img src="static/img/annonse.jpg" alt="" width="150" height="100" /> </center> </td> <td><center> <img src="static/img/annonse.jpg" alt="" width="150" height="100" /> </center> </td> <td><center> <img src="static/img/annonse.jpg" alt="" width="150" height="100" /> </center> </td> <td><center> <img src="static/img/annonse.jpg" alt="" width="150" height="100" /> </center> </td> </tr> </table> <img src="static/img/banner.jpg" name="banner" width="998" height="200" id="banner" /><br /></td> </tr> <tr> <td colspan="2"><div id="ddtabs1" class="solidblockmenu"> <ul> <li><a href="index.php" rel="sc1">Nyheter</a></li> <li><a href="#" rel="sc2">Profil</a></li> <li><a href="?s=grupper" rel="sc3">Grupper</a></li> <li><a href="?s=sok" rel="sc4">Finn en venn</a></li> <li><a href="?s=topp10" rel="sc5">Topp 10</a></li> <li><a href="?s=statistikk" rel="sc6">Statistikk</a></li> <li><a href="?s=spill" rel="sc7">Spill</a></li> <li><a href="?s=vip" rel="sc8">Teenchill VIP</a></li> <li><a href="?s=hjelp" rel="sc9">Hjelp</a></li> </ul> </div></td> </tr> <tr> <td width="821" align="left" valign="top"> <ul id="sc1" class="sub_menu"> <li><a href="index.php">Nyheter</a></li> <li><a href="index.php?filter=mest_leste">Mest leste</a></li> </ul> <? if($logged_in) { ?> <ul id="sc2" class="sub_menu"> <li><a href="hei"><? echo ucfirst($_GET['nick']); ?></a></li> <li id="selected"><a href="hei">Dagbok</a></li> <li><a href="hei">Feed</a></li> <li><a href="hei">Grupper</a></li> <li><a href="hei">Quiz</a></li> <li><a href="hei">Gjestebok</a></li> <li><a href="hei">Venner</a></li> <li><a href="hei">Bilder</a></li> <li><a href="hei">Videoer</a></li> <li><a href="hei">Lenker</a></li> </ul> <? } else { ?> <ul id="sc2" class="sub_menu"> <li><a href="hei">Bli medlem</a></li> </ul> <? } ?> <ul id="sc3" class="sub_menu"> <li><a href="hei">Nye</a></li> <li><a href="hei">Søk</a></li> <li><a href="hei">Største</a></li> <li><a href="hei">Meister grupper</a></li> <li><a href="hei">Opprett ny gruppe</a></li> </ul> <ul id="sc4" class="sub_menu"> <li><a href="hei">Søk</a></li> <li><a href="hei">Medlemmer</a></li> <li><a href="hei">Finn fra direktemeldingsklienter</a></li> </ul> <ul id="sc5" class="sub_menu"> <li><a href="hei">Mest poeng</a></li> <li><a href="hei">Flest stemmer</a></li> <li><a href="hei">Mest besøkt</a></li> </ul> <ul id="sc6" class="sub_menu"> <li><a href="hei">Teenchill statistikk</a></li> </ul> <ul id="sc7" class="sub_menu"> <li><a href="hei">Finn spill</a></li> <li><a href="hei">Highscore</a></li> </ul> <ul id="sc8" class="sub_menu"> <li><a href="hei">Informasjon og fordeler</a></li> </ul> <ul id="sc9" class="sub_menu"> <li><a href="hei">Still spørsmål</a></li> <li><a href="hei">Søk om å bli hjelper</a></li> <li><a href="hei">Faq</a></li> <li><a href="hei">Nivå og poeng</a></li> </ul> <?PHP $nav = $_GET['s']; $array = array("nyheter", "false", "vip", "false", "glemt_passord", "false", "bli_medlem", "false", "bekreftelse", "false", "statistikk", "false", "regler", "false", ); foreach ( $array as $page => $permission ) { if(!$logged_in and $permission != "false") echo "Du må være logget inn for å se denne siden."; elseif(!$logged_in and $permission == "false") include($_GET['s']); elseif($logged_in) include($_GET['s']); else include("nyheter.php"); } ?> </td> <td width="177" rowspan="2" valign="top" style="padding:2px;padding-top:4px;"><? if($logged_in) { ?><div id="UserMenu1_divLoggedIn"> <ul id="usermenu"> <li class="cat"><div class="dropdown" onclick="toggle('menu_profile');"><div class="dropdownbutton"></div> <span class="indent">»</span> Profil</div> <ul class="submenu" style="display: block;" id="menu_profile"> <li><a href="?s=user"><? if($_SESSION['sex'] == "Gutt") { echo "<img src=\"images/icons/01/16/06.png\" width=\"16\" height=\"16\" />"; } else { echo "<img src=\"images/icons/01/16/09.png\" width=\"16\" height=\"16\" />"; }?> <?PHP echo ucfirst($_SESSION['username']);?></a></li> <li><a href="?s=dagbok"><img src="images/icons/04/16/14.png" width="16" height="16" /> Dagbok</a></li> <li><a href="?s=feed"><img src="images/icons/01/16/22.png" alt="" width="16" height="16" /> Feed</a></li> <li><a href="?s=gjestebok"><img src="images/icons/01/16/19.png" width="16" height="16" /> Gjestebok</a></li> <li><a href="?s=grupper"><img src="images/icons/04/16/17.png" width="16" height="16" /> Grupper</a></li> <li><a href="?s=filer"><img src="images/icons/01/16/46.png" width="16" height="16" /> Filer</a></li> <li><a href="?s=lenker"><img src="images/icons/03/16/24.png" width="16" height="16" /> Lenker</a></li> <li><a href="?s=venner"><img src="images/icons/01/16/10.png" width="16" height="16" /> Venner</a></li> <li><a href="?s=quiz&s2=endre"><img src="images/icons/01/16/44.png" width="16" height="16"> Quiz</a></li> <li><a href="?s=bokmerker"><img src="images/icons/01/16/32.png" width="16" height="16" /> Bokmerker</a></li> <li><a href="?s=notisblokk"><img src="images/icons/01/16/42.png" width="16" height="16"> Notisblokk</a></li> <li><a href="?s=nabolag&sted="><img src="images/icons/04/16/02.png" width="16" height="16" /> Nabolag</a></li> <li><a onClick="javascript:wnd('statistikk.php?nick=<? echo $_GET['nick']; ?>');" href="#"><img src="images/icons/02/16/31.png" width="16" height="16" /> Profilaktivitet</a></li> <li><a href="?s=endre_profil"><img src="images/icons/02/16/36.png" width="16" height="16" /> Innstillinger</a></li> </ul> </li> <li class="cat"><div class="dropdown" onclick="toggle('menu_postkasse');"><span class="indent">»</span> Postkasse <div class="dropdownbutton"></div></div> <ul class="submenu" id="menu_postkasse"> <li><a href="/default.aspx?section=msg&page=compose"><img src="images/icons/03/16/29.png" width="16" height="16" /> Nytt brev</a></li> <li><a href="?s=innboks"><img src="images/icons/01/16/04.png" width="16" height="16" /> Innboks</a></li> <li><a href="/default.aspx?section=msg&page=sent"><img src="images/icons/01/16/03.png" width="16" height="16" /> Utboks</a></li> </ul> </li> <li class="cat"> <div class="dropdown" onclick="toggle('menu_search');"><span class="indent">»</span> Søk</a> <div class="dropdownbutton"></div></div> <div class="submenu" id="menu_search">Søk</div> </li> <li class="cat"> <div class="dropdown" onclick="toggle('menu_chillers');"><span class="indent">»</span> Chillere</a> <div class="dropdownbutton"></div></div> <ul class="submenu" id="menu_chillers"> <li><a href="/default.aspx?section=sms&page=send">Test</a></li> </ul> </li> <li class="cat"><a href="/default.aspx?section=search"><span class="indent">»</span> Verv venner <img src="static/img/50.jpg" width="25" height="15" /></a></li> <li class="cat"><a href="http://www.nettavisen.no" target="_blank"><span class="indent">»</span> Informasjon</a></li> <li class="cat"><a href="?s=logg_ut"><span class="indent">»</span> Logg ut (<?PHP echo ucfirst($_SESSION['username']);?>)</a></li> </ul> </div> <? } else { ?> <div id="UserMenu1_divLoggedIn"> <ul id="usermenu"> <li class="cat"><div class="dropdown" onclick="toggle('menu_login');"><div class="dropdownbutton"></div><span class="indent">»</span> Logg inn</a></div> <div class="submenu" style="display:block;" id="menu_login"><? echo "<form name=\"login\" action=\"?s=login\" method=\"POST\"> <table class=\"tekst\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\"> <tr> <td width=\"26%\">Brukernavn<br> <label> <input name=\"username\" type=\"text\" id=\"username\" size=\"20\" value=\"".$_COOKIE['teenchill_user']."\"> </label></td> </tr> <tr> <td>Passord<br> <input name=\"password\" type=\"password\" id=\"password\" size=\"20\"></td> </tr> <tr> <td><label> <input name=\"remember\" type=\"checkbox\" value=\"true\" /> Husk meg </label></td> </tr> <tr> <td><label> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Logg inn\"> <input type=\"reset\" name=\"button2\" id=\"button2\" value=\"Reset\"> </label></td> </tr> </table> </form>"; ?></div> </li> <li class="cat"><a href="?s=glemt_passord"><span class="indent">»</span> Glemt passord</a></li> <li class="cat"><a href="?s=bli_medlem"><span class="indent">»</span> Registrer deg</a></li> </ul> </div> <? } ?><br /> <center><!-- BEGIN ADKING CODE (DO NOT EDIT) --> <table width="120" height="60" cellspacing="0" cellpadding="0" border="0"> <tr> <td align="center" valign="top"> <iframe src="http://www.adking.no/v.asp?u=495&b=2" width="120" height="300" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"> </iframe></td></tr> </table> <!-- END ADKING CODE (DO NOT EDIT) --></center></td> </tr> </table> <script type="text/javascript"> ddtabmenu.definemenu("ddtabs1", <? echo $tab; ?>) </script> </body> </html> <? ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589957 Share on other sites More sharing options...
cordoprod Posted July 14, 2008 Author Share Posted July 14, 2008 Dude, it suddenly worked......WTF ??? Think it was because i forgot ob_end_flush Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-589974 Share on other sites More sharing options...
rhodesa Posted July 14, 2008 Share Posted July 14, 2008 you didn't have ob_end_flush!!!! yeah...without that, everything is buffered and never sent to the screen Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-590020 Share on other sites More sharing options...
cordoprod Posted July 16, 2008 Author Share Posted July 16, 2008 Oh.. sorry I'm a bit clumbsy Link to comment https://forums.phpfreaks.com/topic/114695-solved-replace-with-ob_start/#findComment-591999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.