Re: string problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, if that's the pattern, you can search for >'%< and return anything between this and >%'<; if you can use PCRE try something like
  if ( preg_match('/'%(.+?)%'/X', $str, $matches) ) {
      echo  $matches[1];
  }
Now, if the expression can only have: upper-case letters, numbers & "-", then use "/'%([-A-Z0-9]+)%'/X" instead of "/'%(.+?)%'/X"

weetat wrote:
Hi all ,

 I am using PHP 4.3.2 , MYSQL database and Red Hat Entreprise OS.

 I have the SQL statement which store in $str variable  as shown below :
 How to get the '%WS-X5225R%' from $str variable ?



$str = " SELECT DISTINCT(tbl_chassis.serial_no),tbl_card.card_model, ";
    "tbl_chassis.host_name,tbl_chassis.chasis_model,tbl_chassis.country,";
"tbl_chassis.city,tbl_chassis.building, "tbl_chassis.other,tbl_chassis.status,tbl_chassis.chasis_eos,tbl_chassis.chasis_eol,tbl_chassis.chasis_user_field_1,tbl_chassis.chasis_user_field_2,tbl_chassis.chasis_user_field_3" "from tbl_chassis tbl_chassis,tbl_card tbl_card " "WHERE tbl_chassis.serial_no = tbl_card.serial_no AND tbl_card.card_model LIKE'%WS-X5225R%'";


thanks
--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux