What function should I use?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tonykasdorf
Forum Newbie
Posts: 6
Joined: Wed Mar 31, 2010 7:13 am

What function should I use?

Post by tonykasdorf »

I'm looking for the following functions. Can someone fill in the ?.

$string = "8.5 x 11";

echo $x = ?;
//prints out: "8.5"
echo $y = ?;
//prints out: "11"

Thanks
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: What function should I use?

Post by AbraCadaver »

Depends... If the x and the spaces are constant I would use explode().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
tonykasdorf
Forum Newbie
Posts: 6
Joined: Wed Mar 31, 2010 7:13 am

Re: What function should I use?

Post by tonykasdorf »

Yes, the "space" "x" "space" are constants. the two numbers at the beginning and end of the string are always changing. The numbers will very in size from two to four numbers in length.

I'm looking for the code that can break the two numbers up and give them to me in two separate variables.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: What function should I use?

Post by John Cartwright »

Right.. then explode()
Post Reply