/    Sign up×
Community /Pin to ProfileBookmark

two questions

ok question 1. Can I do something in php that calculates the difference?Like i have two form inputs in one i put 45 and in the other i put 19. then the script will output 26. How would i do this if it is possible.

[hr]

Question two is. Can i have a form with say 10 inputs where i put in #’s like 7,9,6,4,5,2,9,4 etc…. and php will take those #’s and output them in a list from greatest to least. How would i do this if it is possiible

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@Bootsman123Dec 21.2003 — First question:

<?php

$output = $_POST['form1'] - $_POST['form2'];

echo "$output";

?>

Second question:

<?php

$input = "3,4,1,9,6,4";

$array = explode (",", $input);

sort ($array, SORT_NUMERIC);

reset ($array);

for ($i = 0; $i < count ($array); $i++)

{

echo "$array[$i]<br>";

}

?>
×

Success!

Help @Conor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...