I have a piece of code written in PHP inside my javascript tag. I figured it would be better to have all javascript inside my script tag.
So I would need help to convert these 3 lines of code in javascript:
if (strpos($video['thumbs']['master'], '/thumbs_old/') !== false) {
$position = strpos($video['thumbs']['master'], '.flv');
$oldFlipBookThumb = str_replace(substr($video['thumbs']['master'], $position), '.flv', $video['thumbs']['master']);
}
Use the
search()method of the string object – it returns the position of the match, or -1 if no match is foundI could be mistaken, but it looks to me like you are replacing the string “.flv” with the string “.flv”.
In any case, the
substring()method of the string object extracts the characters in a string between “from” and “to”, not including “to” itself.string.substring(from, to)the
replace()method of the string object searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring.string.replace(regexp/substr,newstring)