A new path planning method for Mobile Robots (MR) has been developed and implemented. On the one hand, based on the shortest path from the start point to the goal point, this path planner can choose the best moving directions of the MR, which helps to reach the target point as soon as possible. On the other hand, with an intelligent obstacle avoidance, our method can find the target point with the near-shortest path length while avoiding some infinite loop traps of several obstacles in unknown environments. The combination of two approaches helps the MR to reach the target point with a very reliable algorithm. Moreover, by continuous updates of the on-board sensors information, this approach can generate the MRs trajectory both in static and dynamic environments. A large number of simulations in some similar studies environments demonstrate the power of the proposed path planning algorithm.