I want to let the user to enter three different arguments without changing the order of the output
function check_status($a, $b, $c) {
Some stuff
}
// Needed Output
echo check_status("User", 38, true); // "Hello User, Your Age Is 38, You Are Available For Hire"
echo check_status(38, "User", true); // "Hello User, Your Age Is 38, You Are Available For Hire"
echo check_status(true, 38, "Osama"); // "Hello User, Your Age Is 38, You Are Available For Hire"
echo check_status(false, "User", 38); // "Hello User, Your Age Is 38, You Are Not Available For Hire"
I have tried if statements didn’t went well
2
Answers
You can do a check on the type of the variable and concatenate the string to get the final one. I would do something like:
The output is:
It’s not the shortest way to do it, it’s an example. It’s all about concatenating variables after checking the type.
The concatenation could’ve be done with sprintf instead
For, these cases you can use associative array as a function args.