How to Execute a Specific Part of a Function
If I'm reading you right you're asking a basic program flow-control question.  In PHP, like most programming languages, you can use flow control statements like switch and if to only execute certain blocks of code, or move some blocks into separate functions.

Since it's your own function you're calling here it completely up to you how to handle it. As you gain experience you'll learn ways to determine what to separate out into unique functions and what to just use if statements to control.

To use an if statement, you'll probably need to add a parameter to your function to let you determine which pieces to execute.