Wiki style text input



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

.



Relevant Pages

  • Re: Is this possible with themes?
    ... // load the other table you want here ... I have developed a webpage which are using themes, ... For example one of the table cells contain a image (server ... control) and by selecting another theme then I want the image to appear in ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IE6 chgs to offline while loading page
    ... about the DHCP lease that I assume you will be getting. ... > about the specific sequence of events and the problem ... >>> cable modem I encounter a webpage where IE starts to ... >>> webpage load at all. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: [iptables] sparc64, NAT and MASQUERADE
    ... echo "Aborting iptables initd: no $i executable." ... rm -f "$autosave" ... load the "active" ruleset ...
    (comp.os.linux.networking)
  • Re: IE6 chgs to offline while loading page
    ... about the specific sequence of events and the problem ... >> cable modem I encounter a webpage where IE starts to ... >> webpage load at all. ... >> same webpage being loaded each time with differing ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: A specific webpage has began loading slowly
    ... > old Dell laptop and was running XP with IE for my browser. ... The webpage background begins loading very slowly from the top of the ... > load the same page with no problem and they also run XP with IE. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)