Use array map() fuction instead of custom loop