Jump to content

A little help.


ccherry17

Recommended Posts

Hello

 

I have here a string

 

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit accumsan turpis, vitae rutrum quam cursus id. Sed quis pulvinar eros. Integer vel tellus turpis. Donec tortor dolor, convallis in mollis et, rhoncus eu lacus. Etiam quam risus, fringilla ac tempor in, congue vel felis. Mauris eu luctus augue. Fusce nisl neque, convallis a posuere a, ultricies et metus.

 

What i would like to do with this string is to remove the first word and then put the words on the array. To make things more clearer. Please refer to my sample array below. Thanks

 

<?php 
Array {
[0] => ipsum
[1] => dolor
[2] => sit amet, consectetur adipiscing elit. Pellentesque hendrerit accumsan turpis, vitae rutrum quam cursus id. Sed quis pulvinar eros. Integer vel tellus turpis. Donec tortor dolor, convallis in mollis et, rhoncus eu lacus. Etiam quam risus, fringilla ac tempor in, congue vel felis. Mauris eu luctus augue. Fusce nisl neque, convallis a posuere a, ultricies et metus.
}
?>

 

My problem is that i dont know how to code this using php. Could someone code this for me?

 

I will really appreciate your help!

 

thanks

Link to comment
Share on other sites

$s = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit accumsan turpis, vitae rutrum quam cursus id. Sed quis pulvinar eros. Integer vel tellus turpis. Donec tortor dolor, convallis in mollis et, rhoncus eu lacus. Etiam quam risus, fringilla ac tempor in, congue vel felis. Mauris eu luctus augue. Fusce nisl neque, convallis a posuere a, ultricies et metus.';

$a = explode(' ', $s);
array_shift($a);

 

Your data will now be in the array $a.

Link to comment
Share on other sites

its unlikely that someone will just do it for you. unless its thorpe  :P

 

what do you know about php?

 

you want to put all the words into an array, but your example shows an array with a string in it rather than a seperate word in each value in the array.

to put every word into an array, look into using explode.

 

 

Link to comment
Share on other sites

Hello..

 

I've been searching over the internet and i got to modify the code that was given to me by thorpe.

<?php
$s = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit accumsan turpis, vitae rutrum quam cursus id. Sed quis pulvinar eros. Integer vel tellus turpis. Donec tortor dolor, convallis in mollis et, rhoncus eu lacus. Etiam quam risus, fringilla ac tempor in, congue vel felis. Mauris eu luctus augue. Fusce nisl neque, convallis a posuere a, ultricies et metus.';

$a = explode(' ', $s);

$myarray[] = array_shift($a);

foreach($myarray as $bv => $ms){
echo $ms;
}

?>

 

the error is that, all i get as the result was the word "Lorem" that in fact i would like to remove it.. I  really would like to get this result after using the code above..

 

<?php
ipsum
dolor
sit amet, consectetur adipiscing elit. Pellentesque hendrerit accumsan turpis, vitae rutrum quam cursus id. Sed quis pulvinar eros. Integer vel tellus turpis. Donec tortor dolor, convallis in mollis et, rhoncus eu lacus. Etiam quam risus, fringilla ac tempor in, congue vel felis. Mauris eu luctus augue. Fusce nisl neque, convallis a posuere a, ultricies et metus.
?>

 

can someone help me? I will also work on my own to solve my problem but i need help from you guys..

 

thanks

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.