You are here: Re: Checking string contents « All PHP « IT news, forums, messages
Re: Checking string contents

Posted by Michael Fesser on 06/19/07 13:24

..oO(James_sgp)

>Hi, I`m trying to write code that will check the contents of a
>variable ($distance) to see if it contains the value 'ft'. If it is
>true, I need it to divide the valiable $max_depth by 3.28; then write
>the variable into a MYSQL database. I have tried several different
>ways, but it seems that only the original (not divided by 3.28) value
>keeps getting put into the database. I`m using the line below to do
>the checking:
>
>if(strcmp($distance,"ft")==0) $max_depth=$max_depth/3.28;

This only checks if the value of $distance is the string 'ft':

if ($distance == 'ft') {...}

Obviously this is not enough if $distance contains a real value,
measured in foot, like '1000ft'. Try strpos() instead or a regular
expression.

Micha

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация