Search Results

Search found 2 results on 1 pages for 'user330840'.

Page 1/1 | 1 

  • str_replace problem

    - by user330840
    I am trying to change title data into URL. I need to get rid off all text starting from "deadline" from the following dynamic data which I get from $title: New York deadline May 14th, 2010 (urgent) New Hampshire deadline May 19th, 2010 New Jersey deadline I expect the result should be like this new-york new-hampshire new-jersey Here is the code I have tried $newurl = strip_tags(str_replace("deadline","","$title")); $code_entities_match = array( '&quot;' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'.' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--'); $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-'); $newtitle = str_replace($code_entities_match, $code_entities_replace, $newurl); $urltitle = strtolower($newtitle); Unfortunately, the results are: new-york-deadline-may-14th-2010-urgent new-hampshire-deadline-may-19th-2010 new-jersey- Anyone can help?

    Read the article

  • str_replace between two numerical strings

    - by user330840
    Another problem with str_replace, I would like to change the following $title data into URL by taking the $string between number in the beginning and after dash (-) Chicago's Public Schools - $10.3M New Jersey - $3M Michigan: Public Health - $1M The desire output is: chicago-public-school new-jersey michigan-public-health PHP code I am using $title = ucwords(strtolower(strip_tags(str_replace("1: ","",$title)))); $x=1; while($x <= 10) { $title = ucwords(strtolower(strip_tags(str_replace("$x: ","",$title)))); $x++; } $link = preg_replace('/[<>()!#?:.$%\^&=+~`*&#233;"\']/', '',$title); $money = str_replace(" ","-",$link); $link = explode(" - ",$link); $link = preg_replace(" (\(.*?\))", "", $link[0]); $amount = preg_replace(" (\(.*?\))", "", $link[1]); $code_entities_match = array( '&#39;s' ,'&quot;' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'.' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--'); $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-'); $link = str_replace($code_entities_match, $code_entities_replace, $link); $link = strtolower($link); Unfortunately the result I got: -chicagoamp9s-public-school 2-new-jersey 3-michigan-public-health Anyone has a better solution for this? Thanks guys! (the &#39; changed into amp9 - wonder why?)

    Read the article

1