Skip to content

Instantly share code, notes, and snippets.

@ma3tk ma3tk/gist:6060520
Last active Dec 20, 2015

Embed
What would you like to do?
neapolitan
<?php
$str = "gtgtsgipgttptinggipsppaigsesgpetgstpatetisiesagaeaigttetepitiatsegssieeeeatepaaiagtpieataatppiitgiapsteitatiiatpetetetttgpetpaasipttssstpeeeggtiagtttegtiipestsasgpsepaasapttgattgiatppegitiatpasgatgepttggapesaeetaeissttggieietgspagesiipestipggstttpateptitiaetottissgggtttaipappgstsptttgtpispattgegstltiappseisapgistaiagteeiptptpisaieisagstapeteietgteiisgtiptstgtstasspeatspptitttatteastsgtptgtasggpniaaeteaisett";
$nea = "neapolitan";
$str_len = strlen($str);
$nea_len = strlen($nea);
$j = 0;
$out = "";
for($i = 0; $i < $str_len; $i++) {
if($nea[$j] == $str[$i]) {
$out .= "[" . $str[$i] . "]";
$j++;
if($nea_len == $j) {
$out .= substr($str, $i+1);
break;
}
} else {
$out .= $str[$i];
}
}
echo $out;
@metalunk

This comment has been minimized.

Copy link

commented Jul 23, 2013

$nea_len 使われていない.
$nea[$nea_len] まで見たらあとは飛ばすくらいの処理を書けばいいじゃん

@ma3tk

This comment has been minimized.

Copy link
Owner Author

commented Jul 23, 2013

なおした

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.