Skip to content

Instantly share code, notes, and snippets.

@mvnp
Last active May 12, 2020 23:22
Show Gist options
  • Save mvnp/7b70311253c9dd8a213e4f6e256c8250 to your computer and use it in GitHub Desktop.
Save mvnp/7b70311253c9dd8a213e4f6e256c8250 to your computer and use it in GitHub Desktop.
<?php
$string = 'gmtm xnvgtlml sgcfmz tmw hbvcst mqnj gxr ltrkckj hzbpvj pgnfkhmd tcmpwnk phvx zpsqdhx bcdzdtmm npfbwlt xlwqbj wndfhdf fqx qpnxnsqk lxrcmgjc xlthlfdl xtdql vtznwg jhwd svshbq fmx hvpcwl srxx rhgjql fgx tjlx xzvcgpr gtg zpv sdp cjngcfv kcjpxdv jkvtpjnk zcjmvrbh lsnn gmlpkw nnsvhtff vlwtdch psbqbl rbptvg vpxmvkv rdgwtmj hjn pgh qkm lqpkj qjgmtrqf cdzbbckk fbhsb rpkdph ldk jxhft hrw tcmrdn vwf jjtrk dcdz xmczpt mfvmrs qqbphnnc hcmfkv bwqvdbzx zlsg bvsbdl mjspk ckdndgv sknrzck qvgnhq tsh nltpbns dcpp sbhstq lbkmzbh jmlwkllv cltww nxkwldm bdwn zlzn vhd zkxh xqlxknx xvwh wxhz bldcwc fqt lfmf mqb plvxk nnxplxl ktbdqfd cpxm lprbg tbq tkmvq ggzgtcfv qggswmr nkz xzg gwnfl wrhs mkwj gpggn gchp pfhl cwzrchv qtmxd xzprwf msrwws bwvf xwzbfq srvk kfqrdc ftqwk msrgfhw fmwm wtfgd pbp clmqlfwh hzzjn rmgbz gjzvfhzg jqgshslr nkflqc bjp rsxfnflp cmwvqjld pqqflg xrzrn xqgdnpw cjfzscq dzndcbm gwzgt fzmlvg gcm dbvcsbcv hdcr njk mlwl xsjbjtzz svt lgc xntlpmr mrjnhmgf swntq tdd qcsfvx jgslgvdf krztn nggpm pjdjrpn zqgrk mcsdh hvclhvk ftm khct znqfpcpw mjsmgssg lsxxhjwh lwcj gvwpbk zkxj rnhdtxgx ftmdzb cpcfhf jnd dqnpqw dwn jskpn qgbcrjzx mdmhtt kbbjthfl tlv lvhqnb ldht mpcxgz hcqgswp nqmkw cpfpdsn dbcbc mvqw vfjrlhj lxs wmglxhgv jbhstvvs bfq dvxlmr mjgjfgv fdrctz spdlgrf xwpcqgb kbqqhwb wkxgklq ddsgvxqx xfrcqt mvwf wdvrlbc hrmn cdxrkczw qlcsjk lqmgwq tjl glkqp zfsft vhfptfg dzkw qglltnd wcccwx bsdb zhddx spfkq swcxvbx qsznpfkr zslthtjv ljrltk vrvpzlfj mhzzrvs tqmndn pstqctwf kpzlgzg gtrq pdwffz dzx ktgnd fdk gwxwwngn lfjxb wbg glkgrs mmphjqf zgxllrxn sjzsttzg gpnlvb fxrct wnjp ntwvtzk xmvzjjs zcb zhkzrl kswskdjh lbtzh qsjh gzldc ftqpqqlw shwl wwdzlsc ztsbw jlfzqbpl bbqtzgrj rmrrgsp sqzk szhvwfw cxdv hwhpsdp drkp vlkzkc rpb kgfdhk lwbwxpzk tgdwwnsj ltcqs zblpzpv bvlp hdsnblpv dbq nlkz tmzjj qdrvhw sjmfn fpg cmmqz grwqhlh gjtbfws nwfxjpq qrk qspx dqhskm zphnxfn gspzcbrx przjqwr kfbh wmvjfwxr gfwb fcwntkz zpf cmcxptrh bqrxn lmppks wznjt dhxjnjlh hqdvpzw lgk qthd stn xwzkkx jvzmv dtp ppq zqbdl smphb kldknq tlrvbxsr zbjs khfhxcx hgfhv hrbbrbbs tggqvh cnvqd pjqxt mcvvw rht dzq ggsxpj mpvxms rbgwkbmc nvlkwzw wgp mwlkvdpq sfbq jtrzxqb xqdq zckjhmkc tsdm cthtzg fsbxxsk spcvh jhtr xphs nmzls fqnws mlnvq xdqlljf tflpsr ccgnwl rtxwqkt hmccs fnrqz lvksdrtr kqvpcvmr nbp kjgh clxzknq vkj qdfljlgp xtfl lpht zzlh mchgww gqwsvzlv zdbh hmgq xfb xcfn dkmkglqd zlvwjfmj dwj xgxdm fzxzmbz rfd lwzqsqsm dwz mnr pwdcwq rrmjdln rcg bfx bqrntz vpbrbg lmfqnw fclpdfh nxvhrh zfmrf wpr wbthbqs qdczwnl ssm dlbdshh fqvgks sssxx lsd cfbmmb dfxd lgq swh ntt vtbwbrc xch jxxq kzq wqcbpr xpk ggdqkp flkc bcng hgggdns dkqmcb zpm bqlqcp mbw fqp rdm zmq kjpgdp kpzcpsf gxtj jznbbfsr brm mwlg vnvdmtks lkpvtsd lmgjgv vqgzvf vjszvcrm svnttdtp fgsz mcjhb kssmc vrkgtpf slnttp qbmclrrd csdcm tqnqm qpvflxtq djhrq jrhwd qcznvsf txfqs sgzvqsnf xlkgwmlm qvxbr lhhb mcmpwjlt lzzrzp lvfqphvj slncfr fvmsqbhq jfkcdfxq wsjwnj clbpgx mjsh ccxvx bfxjbwj hxtmfqm tzpqtcnl ntz hbkg hpfd hzhdsgsc pgqktlpb jhrxc tbfrz hfpcwj sqxx wfdx rxcbt ckkk lmcfxjsn vzzvr zhmxdcxs mfrfftw ddh dpfxhkw hglhk gprmzpb xznlhrq brm jjdnztgs krvn qdr qqrzkdzr mzg fht dcbflwrh skrmqcc cxznmfdx hgpxwqg ngpdnpw tjnl qpc xtk sjg bjkhd frnnn qtjvnjs khnvgql chmrrd gzvn jtgsq clfbtqfm dml grqzx nhq gccjx wsdrk qkghs jhpvmv xnh smxb txzrh tzltk fnxhd rqqp slpzdvk fktc plfp slq szfsmnnr hmtntnn kbdfrh vgfzgqp nkkxlbwj fzlgv dszh bsrt jbnftt cbqgd jqbnd zbrxkrn rrd hzf cqpzvq vrmbzk wdlnhm zltthzp gnxqr qfwxhb bmmm wgnz mxb pztcvkg sdzpsj gsxfrnts jzlzscrz sdnz qpjxlqfk hshhzlhb xzvxsvq wbdgljv kdcgvs wpx qzpqg dxzgs xzbpzq rhkklr zldzwtk jrjfmmrt nvb tfm fnrvwzv bmpzqx pcjqgqcc ztms gcrrtftm wktcg tqggk dvdw cqz rzjjwk tmjh szbzxrz srwcxd rtswgvx wfd rkznd jcqcnnjl sstjg wsjj cdlkmfqx sfcs xgzd bqxs wvxslc rzrd pjbrmt gnxchpn skrfb kbxlz bnv szrvg czsbmn tslqcjtg qkk dmhn vskvskhc mfsgtj gxjgh ltqm tcdck qlgwpwhc lncg xts vlnw dqr zjbr qnbpk qpjmc';
// Inicia a nova string
$new_string = "";
// Letras a serem avaliadas na última posição
$array = ['v', 's', 'h', 'z'];
foreach (explode(" ", $string) as $value) {
// Explodindo denovo para pegar a última letra
$new_letter_array = str_split($value);
// Armazenando a última letra da string atual do foreach
$last_letter = end($new_letter_array);
// Comparando a última letra com $array pra ver se é false ou true
if(in_array($last_letter, $array))
{
// Verificando se a string atual tem o comprimento de 3 letras
if(strlen($value) === 3) {
// Concatenando em $new_string para retornar a nova string
$new_string .= $value . " ";
}
}
}
echo $new_string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment