Skip to content

Instantly share code, notes, and snippets.

@Akkiesoft
Created May 6, 2013 13:32
Show Gist options
  • Save Akkiesoft/5525167 to your computer and use it in GitHub Desktop.
Save Akkiesoft/5525167 to your computer and use it in GitHub Desktop.
RadioLineのPositionをまとめてずらすアレ、というのを発掘した。2011/2/12ごろに作ったもので、今のバージョンで使えるのかわからない。
<?php
$in = "";
$out = "";
$num = "";
if(isset($_POST['gogo'])) {
$in = $_POST['input'];
$num = intval($_POST['num']);
$suffix = $_POST['suffix'];
$text = split("\n", $in);
foreach($text as $line) {
if (preg_match('/Position\=([0-9]+)/', $line, $match)) {
if ($suffix == 'plus') {
$replace = intval($match[1]) + $num;
} else if ($suffix == 'minus') {
$replace = intval($match[1]) - $num;
}
$out .= preg_replace('/Position\=([0-9]+)/', 'Position='.$replace, $line);
} else {
$out .= $line;
}
}
}
?>
<!DOCTYPE html>
<html jang="ja">
<head>
<meta charset="utf-8">
<title>RadioLineのPositionをまとめてずらすアレ</title>
</head>
<form action="radioline.php" method="post">
<textarea style="width:800px;height:400px;" name="input"><?php print $in; ?></textarea><br>
↓ずらす数値 <input name="num" value="<?php print $num; ?>"><br>
↓<label for="minus"><input type="radio" id="minus" name="suffix" value="minus">前にずらす</label>&nbsp;&nbsp;&nbsp;
<label for="plus"><input type="radio" id="plus" name="suffix" value="plus">後ろにずらす</label>&nbsp;&nbsp;&nbsp;<br>
↓<input name="gogo" type="submit" value="やるべし!やるべし!"><br>
<textarea style="width:800px;height:400px;" name="output"><?php print $out; ?></textarea><br>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment