Jump to content

pastet89

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pastet89's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello all! I need some help: I have this string: $string = "a.whatever.could.stay.here.b"; I need by having just "a" and "b" to delete all the string and to have finally: $final_string = ""; On the place of ".whatever.could.stay.here." there could stay really everithing - " ", ",", "." "?", "'", "[", "/", every letter, every number - EVERYTHING. Just the beginning "a" and the end "b" are defined and known. I know that here I can use something like preg_replace ( mixed $pattern , mixed $replacement , mixed $subject) but I don't know how to define the $pattern part of the function and I am not absolutely sure that this function will do something here... Can you help me? ???
  2. Hello all! I am wondering what to do with an issue I can't solve from hours... The promlem is: I have this code: $html2 = <<<RR <form method='post' action='request.php'> <input type='hidden' name='broj' value='359878791261'> <table bgcolor='#80ff80' border='0' cellpadding='0' cellspacing='0' width='331'><tbody><tr bgcolor='#ffffff'><td colspan='4' height='4'></td></tr><tr><td colspan='4' height='1'></td></tr> <tr bgcolor='#82fc74'><td class='title' colspan='4' height='18'> <b>Internatinal</b> - Club Friendlies</td></tr><tr bgcolor='#82fc74'><td class='match-light' width='45' height='18'> 12:41</td><td class='match-light' colspan='3' align='right' width='286'>Януари 16 </td></tr><tr><td colspan='4' height='1'></td></tr><tr bgcolor='#cfcfcf'><td width='45' height='18'> <img src='http://cdn.livescore.com/img/flash.gif' border='0' width='8' height='8'> 90'</td><td align='right' width='118'></td><td align='right' width='118'>Leverkuzen</td><td align='center' width='50'>? - ?</td><td width='118'>Frankfurt</td></tr><tr><td colspan='4' height='1'></td></tr><tr bgcolor='#cccccc'><td width='45' height='18'> FT</td><td align='right' width='118'>Hanover</td><td align='center' width='50'>? - ?</td><td width='118'>Augsburg</td></tr><tr><td colspan='4' height='1'></td></tr><tr bgcolor='#cfcfcf'><td width='45' height='18'> 18:00</td><td align='right' width='118'>Yung Boys</td><td align='center' width='50'>? - ?</td><td width='118'>Vinterture</td></tr><tr><td colspan='4' height='1'></td></tr></table> RR; $from = "</td><td align='right' width='118'>"; $to = "<input type='radio' value='' name='utakmica'></td><td align='right' width='118'>"; $html2 = str_replace($from, $to, $html2); echo $html2; As you can see here: http://livescore-bg.net/lolo/proba2.php everything is ok with the $from string, when before it there is "FT" or "18:00", but in the first of the three replacements, where before "</td><td align='right' width='118'>" there is ' , the replacement is full with errors. DO you have any idea why is that and what function am I supposed to use, to succsesfully replace the three replacement strings without errors, like the last two?
  3. addbuet, Thanks a lot, it worked!
  4. Hi all! I really need some help :queasy: I have these two things: $string = "blabla<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>"; $array = array("b1", "b2", "b3"); What am I trying to do with the code , is to insert in every value='' the appropriate value for it. That is the final string I need: $final_string = "blabla<input type='checkbox' value='b1' name='utakmica'>blaablaablaa<input type='checkbox' value='b2' name='utakmica'>blaablaablaa<input type='checkbox' value='b3' name='utakmica'>"; I tried the code, which worked if the value of the string was "ac ac ac", and instead of $array_string = explode("' name='utakmica'",$string); I used $array_string = explode(" ",$string); . But when I inserted the actual values I need: $array = array("b1", "b2", "b3"); $arraysize = sizeof($array); $string = "blabla<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>"; $array_string = explode("' name='utakmica'",$string); for ($i = 0; $i<$arraysize; $i++) { $combine_array = "". $array[$i] ."". $array_string[$i] .""; $final_string = "$final_string ". $combine_array .""; } echo $final_string; what I get was: b1blabla<input type='checkbox' value=' b2>blaablaablaa<input type='checkbox' value=' b3>blaablaablaa<input type='checkbox' value=' Why is this error happening when I replace "ac ac ac" with more difficult string...? Do you know how can I get the desired stirng: $final_string = "blabla<input type='checkbox' value='b1' name='utakmica'>blaablaablaa<input type='checkbox' value='b2' name='utakmica'>blaablaablaa<input type='checkbox' value='b3' name='utakmica'>"; , using just these two things: $string = "blabla<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>"; $array = array("b1", "b2", "b3");
×
×
  • 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.