getting a file name from a folder into page using php or javascript -


if it's possible, can 1 please me made youtube example. see in plnkr link http://plnkr.co/edit/44eqksjp3gl566wczkl6?p=preview

for example "embed" folder , in "embed" folder have files name "p9zdcra9gce" "qrmou4gu3uu"

as see them in here

<div class="ytid" data-str="p9zdcra9gce">video 1</div> <div class="ytid" data-str="qrmou4gu3uu">video 2</div> 

if it's possible want like, when ever add file like, "p9zdcra9gce.html" or "qrmou4gu3uu.html" in folder "embed", , automatically on index page next other video buttons become this

<div class="ytid" data-str="p9zdcra9gce">video 1</div> <div class="ytid" data-str="qrmou4gu3uu">video 2</div> <div class="ytid" data-str="anotherfile">video 3</div> <div class="ytid" data-str="anotherfile">video 4</div> <div class="ytid" data-str="anotherfile">video 5</div> 

i have tried in youtube , seems work want how put file name in here video 1 replace "p9zdcra9gce" , remove file extension become "p9zdcra9gce" instead of "p9zdcra9gce.html" in video https://www.youtube.com/watch?v=v3uazvf-zf4

you should able remove .html part str_replace() function this:

$file = 'p9zdcra9gce.html'; echo str_replace('.html', '', $file); 

where $file name of file want "edit", then, in str_replace function first argument part wish replace, second want replace , third want replace it. in case want replace '.html' empty string, "". can read more str_replace() on official php docs - http://php.net/str_replace

edit:

you can use in combination function video this:

$id = 1; foreach (glob('*.html') $file) {     $file = str_replace('embed/', '', $file);     $file = str_replace('.html', '', $file); ?>     <div class="ytid" data-str="<?php echo $file; ?>">video <?php echo $id++ ?></div> <?php } 

store video files in 1 directory , no other files should stored there otherwise you'll fetch them glob() long have .html file extension. modify path of glob() point directory this: glob('embed/*.html')


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -