How can I 'bridge' and unbridge connections between two inputs

How can I make a non physical switch so that when in one state the two wires will be connected and in another they are not.
IE: Current going through into I/O 22 and being connected or not connected to a wire leading from I/O 23.
I am using a ardunio mega

It is kinda like a no moving parts button, if you will.

Use an analogue switch like the 4066, there are four in one IC.