02-05-2009, 02:26 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Sep 2008
Posts: 39
Thanks: 9
|
Creating a function?
I am not sure how to go about creating a function. I have a search script that when returns the result there are 4 specific columns that will have either 11,12,13,14,15 but only one number per column. Order depends on how they enter them in (ex. col_1 = 13, col_2 = 11, col_3 = 15, col_4 = 12 OR col_1 = 11, col_2 = 15, col_3 = 13, col_4 = 12 and so on). Each of the numbers needs to be have a decimal added in the middle (ex. 11 = 1.1, 12 = 1.2 and so on). This is what I have happening right now.
PHP Code:
if($row['cargo_11'] == 11) {
echo '1.1';
} elseif ($row['cargo_11'] == 12) {
echo '1.2';
} elseif ($row['cargo_11'] == 13) {
echo '1.3';
} elseif ($row['cargo_11'] == 14) {
echo '1.4';
} elseif ($row['cargo_11'] == 15) {
echo '1.5';
}
But I have one for each cargo_type. Is it possible to write a function that will do this in a shorter more efficient way?
I hope all that makes sense.
__________________
Trying to learn all I can about PHP. Teach me what you know...
|
|
|
|