In this paper we present a biologically inspired nonlinear controller for swarms flocking in dynamic environments. Based on some observations in natural swarming phenomena and certain hypothesis proposed by biologists, we present a general decentralized controller to make swarm members flock together, which can be applied into certain related applications such as robot swarm or mobile sensor networks. We assume that during the process of flocking, each swarm member can sense and interact with its nearest neighbors while following certain path clues from the potential profile of the environment. With a new set of mutual interaction functions and the assumption of strongly connected graph, the controller is proved to enable the velocities of all swarm members to converge to a common value with bounded errors. The advantage of this controller is that only local and relative information are needed to achieve stable group behavior for either fixed or dynamic swarm topology. In addition, the topological graph of the swarm considered in the controller is the sensing rather than the communication graph. As a result, the communication module is not needed for the implementation of the agents in engineering. We also discuss the convergence time of the swarm for one dimensional case. A few sets of simulations, including the case of agents being lost during swarm�s motion, are presented to verify the feasibility of the proposed controller.