Your 401k plan is very useful when you reach the age of retirement. For this reason, it is not advisable for you to get funds from your 401k plan. However, there may come a time when you are in desperate need of money and you have no other choice but to consider 401k hardship withdrawal.
Borrowing from 401k may be allowed by the government by there is no rule stating that plan administrators are required to offer them. This option will depend on your plan administrator and thus you need to verify with them first if this is option is available for you. Also, you cannot just withdraw funds from your 401k just because you are in need of money. 401k hardship withdrawal can only be used under certain circumstances.
