BusyBeet
-
Posts
1 -
Joined
-
Last visited
Never
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Converting Perl code to PHP
in PHP Coding Help
Posted
Since I'm fairly new to PHP, I don't know the proper syntax for making an array of the content and spliting it by newline, then running through some elseif logic to check for types of content then substituting in a foreach loop.
For example, in Perl I had:
@lines = split(\n,$tableofcontents);
foreach (@lines, $wz) {
if ($wz =~ '[0-9]\.(.*?)\W' ) {
s|([0-9]\.(.*?)\W|<a href=\"\#H$1\"\>$1. $2\<\/a\>\<br\>\n|g;
etc, etc...
SO I tried rewriting it as...
$wordz == explode('\n',$toc);
foreach ($wordz as $wz) {
if ($wz =~ '[0-9]\.(.*?)\W' ) {
...It's erroring on the foreach line - what is the proper way to make and loop an array from one form field?
Thanks!
BB