You are here: Wiki style text input « PHP Programming Language « IT news, forums, messages
Wiki style text input

Posted by Dan Pearce on 06/20/06 15:10

I have a text file called test.txt which is I am trying to get to load
into a webpage. This is simple enough, but I am trying to make it so
that it recognises certain formatting, similar to how wikipedia pages
work.

so, my text file contains ONLY the following:

This is /just/ some test text *to see* if the PHP works
and to /*evaluate*/ what it actually does

The intention is that /just/ will show as italic, *to see* will show as
bold and /*evaluate*/ will show as bold italic.

Creating the text inside the page works fine.

<?php
$s = 'hello. /this/ works *bolding* works. /*Both work*/!';
$search = array ( '@/(.*?)/@si',
'@\*(.*?)\*@si');
$replace = array ( '<i>\1</i>',
'<b>\1</b>');

echo preg_replace($search, $replace, $s);

?>

However when I try and read from a text file using

$s = file('./wiki.txt');
$search = array ( '@/(.*?)/@si',
'@\*(.*?)\*@si');
$replace = array ( '<i>\1</i>',
'<b>\1</b>');

echo preg_replace($search, $replace, $s);

?>

All that is shown is the single word 'Array'. This confuses me a lot as

<?
$s = file('./test.txt');
print_r($s);
?>

shows that the text is being read into the page
Array ( [0] => This is /just/ some test text *to see* if the PHP works
[1] => and to /*evaluate*/ what it actually does )

If someone can see what is going wrong here I would be most grateful.

Kind regards

Dan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация