Foraging is the act of searching for, and when found transporting objects to one or more sinks. Although foraging can be accomplished by one single robot operating individually, it can be supported more efficiently by multiple robots operating collectively. The efficiency of the group of robots can be sufficiently improved through coordination. Pheromone-based communication is well suited for the coordination of swarm of robots. It is one of the main subjects of swarm intelligence that provides intelligent global behaviors from simple local behaviors. The goal of this work, is to study the benefit of collective foraging via the implicit recruitment when one agent alerts the others to the location of food. We present therefore, a multi-agent foraging algorithm named Cooperative Switching Algorithm for Foraging (C-SAF) inspired from the classical ant system, where agents use pheromone to collectively search and avoid already visited cells, and to communicate the food location. C-SAF provides a quick search, optimal paths to return to nest and quick exploitation of food. We then generalize the algorithm to produce a flexible and extensible framework for foraging, that can be reused or extended by other foraging algorithms. A qualitative comparison with some related search and foraging algorithms is presented in this paper. A quantitative comparison shows that our algorithm outperforms the reference c-marking algorithm across a range of scenarios that differ in terms of agent, environment and food parameters.