| | |
Find String in PHP Ready easy function
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Better way to find String in PHP ! instead of substring and other php function , This function takes Start and End , and it will return the String in between in another variable ! you can call it easily
function findtxt($start,$end,$str,&$var) { if(stristr($str,$start) && stristr($str,$end)) { $txt_pos_s = strpos($str,$start) + strlen($start); $txt_pos_e = strpos($str,$end,$txt_pos_s); $txt_length = $txt_pos_e - $txt_pos_s; $txt = substr($str,$txt_pos_s,$txt_length); $var = $txt; return TRUE; } else { return FALSE; } } //Call the function $str="Address 1: Cairo 14 Street </br> Address 2: bla bla bla "; findtxt('Address 1:','Address 2:',$str,$s1); // then you can remove the html tags from the result string which is $s1 $s1=strip_tags($s1);
Similar Threads
- How could i find string that it's the end with "," and "." ? (Java)
- string in php (PHP)
- search for string in text file then find a different string after (C++)
- find string in txt file (C++)
- How to allow php tags with strip_tags function (PHP)
- Better Solution? String Builder? Censor List Function (ASP.NET)
- Search for a string in a variable--- (PHP)
- Problem with string variable in void prnt function (C++)
- Redirected to "http://search-to-find.com/sec.php?qq=car&pin=37049" (Viruses, Spyware and other Nasties)
| Thread Tools | Search this Thread |
# 5.2.10 access alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube



