Jump to content

Add Period to end of Sentence


unemployment

Recommended Posts

How can I add a period at the end of the sentence with this..

 

if($i > $max) break;
if($i == $max || ($i == count($information) && $i > 1)) echo ' and ';
else
{
if($i > 1) echo ', ';
}

if ($info[0] == 'credentials')
{
echo "credentials";
}

if ($info[0] == 'specialties')
{
echo "specialties";
}

if ($info[0] == 'stageofdevelopment')
{
echo "stage of development to {$info[1]}";
}

$i++;

Link to comment
Share on other sites

maybe instead of directly echoing the value, assign the value to a string with .=

 

like:

 

$string = 'monkeys ';
$string .= 'eat ';
$string .= 'banana\'s';
$string .= '.';


echo $string; // outputs monkeys eat banana's.

Link to comment
Share on other sites

not sure i can work out where the sentences start and end but maybe passing the output to a concatenating string  and then add it to the final string?

 

The sentence would say something like.. you have updated you specialties, credentials and stage of development.

 

I need to add in the period at the end.

 

Keep in mind that the sentence could also say something like.

 

The sentence would say something like.. you have updated you specialties and credentials.

 

Link to comment
Share on other sites

maybe instead of directly echoing the value, assign the value to a string with .=

 

like:

 

$string = 'monkeys ';
$string .= 'eat ';
$string .= 'banana\s';
$string .= '.';


echo $string; // outputs monkeys eat banana's.

 

Even if I assign it to a string it will eventually be echoed anyway.

Link to comment
Share on other sites

Even if I assign it to a string it will eventually be echoed anyway.

 

indeed, but this way you can alter the output.... which is what you wanted  :shrug:

(a string with a dot at the end)

Link to comment
Share on other sites

Even if I assign it to a string it will eventually be echoed anyway.

 

indeed, but this way you can alter the output.... which is what you wanted  :shrug:

(a string with a dot at the end)

 

I can't see that working with what I have.  If it does please teach me.

Link to comment
Share on other sites

if you dont want to try the string method why not just echo out a period after the loop ends the sentence? or is it looping several sentences in a row?

 

I would do that but it puts a space between the last word and the period like this . 

 

Which is pretty annoying. Any ideas on how to remove the space that an echo adds in?

Link to comment
Share on other sites

here comes the irony, pass it to a string and use rtrim() (trims space from the right) you could probably do that directly into the echo statement too though, I just want you to use strings :)

 

Turning the text based words into a string is no big deal, but how would I turn this into a string?

 

if (($info[0] == 'companywebsite') || ($info[0] == 'personalwebsite'))
{
?>
website to <a href="<?php $info[1]; ?>"><?php echo substr($info[1], 7);?></a>
<?php
}

By the way, putting rtrim() around the echo didn't work for me.

Link to comment
Share on other sites

if (($info[0] == 'companywebsite') || ($info[0] == 'personalwebsite'))
{
$info1=$info[1];
        $web="website to <a href='$info1'>";
        $web.=substr($info1, 7);
        $web.="</a>"
echo $web; 
}

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.