<?php $template = file_get_contents('lanes.template'); $sign = rtrim(file_get_contents('lanes-sign.template')); $sign_template = array(); for ($i = 1; $i <= 12; $i++) { $sign_template[] = strtr($sign, array('@' => $i)); } $sign_template = implode(",\n", $sign_template); $template = strtr($template, array('SIGN' => $sign_template)); file_put_contents('lanes.json', $template);