I’m creating a language learning website and in one section I’d like to have many pages each with a table of verb conjugations. It’ll take ages to do each one manually, so I’d like to know if there’s a way of creating a datafile that can be read from an html page, perhaps javascript or php, and data imported into the table.
Each verb would have its own datafile, which would contain an array that ideally looked like this:
pren,prenn,av,ys,yn,owgh,ons,ir,is,sys,as,syn,sowgh,sons,as,en,es,a,en,ewgh,ens,ys,sen,ses,sa,sen,sewgh,sens,sys,iv,y,o,yn,owgh,ons,er,en,es,a,en,ewgh,ens,ys,ys
Then in the table I would specify which datafile to import, and call different entries in the array at the appropriate places to build up a verb table, so 1 and 3 would give prenav, 1 and 4 would give prenys, etc.
Does anyone know how this could be done?
You can do this in PHP, using a combination of
file_get_contentsandexplode.file_get_contentswill read the datafile in and you can store it in a string, like this:Once you have the datafile in a string variable, you can use
explodeto split it into an array, like this:Now you can access the members of the array with a numeric index, although one thing to note is that it is a zero-based index. So it would be 0 and 2 that gets you ‘prenav’, not 1 and 3: