When a person charged with felony is believed by the magistrate before whom he is brought to have on his person a dangerous weapon, or anything which may be used as evidence of the commission of the offense, the magistrate may direct that the accused be searched in his presence, and that the weapon or other thing be retained subject to his order, or to the order of the court in which defendant may be tried.
A.R.S. § 13-3931