함수 lastIndexOf()

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:36 판 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 JavaScript[ | ]

var url = "http://example.com/wiki/http-server";
var n = url.lastIndexOf("http");
console.log( n );
// 24
var str = "친구야, 안녕! 너는 나의 가장 좋은 친구야.";
var n = str.lastIndexOf("친구");
console.log( n );
// 21

2 PHP[ | ]

$url = "http://example.com/wiki/http-server";
$n = strrpos($url, "http");
var_dump( $n );
# int(24)
$str = "친구야, 안녕! 너는 나의 가장 좋은 친구야.";
$n = mb_strrpos($str, "친구", "UTF-8");
var_dump( $n );
# int(21)
$str = "친구야, 안녕! 너는 나의 가장 좋은 친구야.";
$n = strrpos($str, "친구");
var_dump( $n );
# int(47)

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}