Jump to content

If / Equality / String Fail


chaosxkitten

Recommended Posts

Here's all of it, maybe the error is somewhere else. I added a check that would print the $fw variable, and everything prints as it should, but my webpage is here and not working well http://easlnx01.eas.muohio.edu/~meadecm/project02.php

 

 <?php

//Returns the first word of a paragraph
function getFirstWord($p,$x) {
    $str = $p[$x];
    $word = explode(" ",$str);
    return $word[0];
}

// Opens the constitution text file, writes to a variable, explodes.
$data = file_get_contents('constitution.txt');
$paragraphs = explode("&",$data);


// Formats the Preamble.
echo "<p><em>$paragraphs[0]</em></p>";

// Runs through some if statements to determine the tags to use on remander.

$n = 1;

do {
    $fw = getFirstWord($paragraphs,$n); 
    if ($fw == 'Article'){
echo "<h2>$paragraphs[$n]</h2>";
    }
    elseif ($fw  == 'Section'){
echo "<h3>$paragraphs[$n]</h3>";
    }
    elseif ($fw == 'Amendment'){
echo "<h3>$paragraphs[$n]</h3>";
    }
    else{
echo "<p>$paragraphs[$n]</p>";
    }
    $n += 1;
    echo "\$fw=$fw\n";
}  while (count($paragraphs) >= $n) 

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.