# PHP text fileness

**URL:** <https://forum.kirupa.com/t/php-text-fileness/21190>\
**Category:** programming\
**Created:** [May 18, 2003, 5:47pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190 "2003-05-18T17:47:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nobody](https://forum.kirupa.com/u/nobody)\
**Post date:** [May 18, 2003, 5:47pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/1 "2003-05-18T17:47:04Z")

</div>

Once again, this has probably been asked numerous time before but I don’t exactly know what this is called or how I would go about searching for it. So sorry for that one.

What I want to do is have all the information on one of my pages be drawn from a txt file through php. I’m doin it all in html, no flash. So if you can point me to a tutorial or just tell me the code it would be great. I’m sure its relatively easy and everything, I’m just new to all of this.  
Thanks in advance

-xxviii

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 5:51pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/2 "2003-05-18T17:51:33Z")

</div>

what do you mean by ‘drawn’? 🙂

if you just wanted the text to be included in your html file from a text file, use this

```php
<?php include 'file.txt' ?>

```

et voila… whatever in the text file will appear in the html… 🙂

[size=1]i think i missunderstood you though… did i :q:[/size]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 5:52pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/3 "2003-05-18T17:52:55Z")

</div>

no, thats probably it, i knew it was excessively simple, let me test it out real quick and I’ll tell you

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 5:57pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/4 "2003-05-18T17:57:20Z")

</div>

yup, that was exactly what I needed  
thanks a lot

can I use HTML tags in the txt file?  
or if not can you direct me to a site or something that talks about formatting…

thanks a lot again

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 5:58pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/5 "2003-05-18T17:58:40Z")

</div>

Yep! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:18pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/6 "2003-05-18T18:18:04Z")

</div>

yup… i figured that out hella fast, my page looks better now too, thanks a lot

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:23pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/7 "2003-05-18T18:23:31Z")

</div>

😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:39pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/8 "2003-05-18T18:39:27Z")

</div>

if i can just ask, what did this do

did you write you site in the .txt file then use

```php
<?php include 'file.txt' ?>

```

to display it on your site

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:39pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/9 "2003-05-18T18:39:53Z")

</div>

ok another question… I want to randomlly load up an image onto my site… what I want to do is have a file such as image.txt have information like this

```php
image 1.jpg
image 2.jpg
image 3.jpg

```

(that would be in proper html, thats just an example)

I then want to just have it randomly select a line and display the html code… i know its possible because ive seen a few examples, but couldnt figure them out…  
so if you could tell me how to do that as well it would be great  
thanks a ton

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:43pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/10 "2003-05-18T18:43:10Z")

</div>

the ‘include’ is a php function that includes any kind of files in the script… what the script above does is merely display the contents of the textfile in the html file the script is embedded into…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:44pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/11 "2003-05-18T18:44:56Z")

</div>

oh… sorry, i wasnt clear  
i got the other thing to work out, this is a whole different problem, i just didnt want to create a new thread

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:46pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/12 "2003-05-18T18:46:05Z")

</div>

lol… that was for chris 😛

anyways, this thread might help you  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21058&highlight=\*random+image\*](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21058&highlight=%2Arandom+image%2A)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:49pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/13 "2003-05-18T18:49:09Z")

</div>

hrmm… im still confused… i guess ill just do javascript for now

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:53pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/14 "2003-05-18T18:53:03Z")

</div>

ok… what i would do is create an array will are the image files like this:

```php
<?php
$images[0] = 'image1.php';
$images[1] = 'image2.php';
$images[2] = 'image3.php';
$images[3] = 'image4.php';
$images[4] = 'image5.php';
?>

```

and then have this in the html:

```php
<img src="<php? $rand = rand(0,4);
echo $images[$rand];
?>" ></img>

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:59pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/15 "2003-05-18T18:59:13Z")

</div>

thanks ahmed, but i already got it with javascript… but I think I’ll give yours a shot too to see which one i like better  
thanks for bein so helpful

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 7:01pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/16 "2003-05-18T19:01:44Z")

</div>

lol… no problem 😉  
for an effect like this one i would use JS, it’s client side… theres no need to get the server invloved in generating a random image you know 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 7:06pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/17 "2003-05-18T19:06:32Z")

</div>

ohh ok  
i never understood client and server side but now that i think about it its pretty obvious… i guess php would be kind of overkill… thanks again times a miilion, btw, your site with asian person looks pretty cool

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 7:12pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/18 "2003-05-18T19:12:32Z")

</div>

lol :beam:…

I do what i can 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 7:15pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/19 "2003-05-18T19:15:46Z")

</div>

\*the asian person would b me…🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 7:17pm UTC](https://forum.kirupa.com/t/php-text-fileness/21190/20 "2003-05-18T19:17:21Z")

</div>

yes it would

[Next page](https://forum.kirupa.com/t/php-text-fileness/21190.md?page=2)
