ccherry17 Posted February 8, 2012 Share Posted February 8, 2012 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 https://forums.phpfreaks.com/topic/256658-a-little-help/ Share on other sites More sharing options...
trq Posted February 8, 2012 Share Posted February 8, 2012 $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 https://forums.phpfreaks.com/topic/256658-a-little-help/#findComment-1315722 Share on other sites More sharing options...
spiderwell Posted February 8, 2012 Share Posted February 8, 2012 its unlikely that someone will just do it for you. unless its thorpe 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 https://forums.phpfreaks.com/topic/256658-a-little-help/#findComment-1315723 Share on other sites More sharing options...
ccherry17 Posted February 8, 2012 Author Share Posted February 8, 2012 I do not know php sir.. What i would like to do on my string is to removed the first word then put the words on the array.. I was hoping for someone to code it for me.. thanks Link to comment https://forums.phpfreaks.com/topic/256658-a-little-help/#findComment-1315726 Share on other sites More sharing options...
dflow Posted February 8, 2012 Share Posted February 8, 2012 I do not know php sir.. What i would like to do on my string is to removed the first word then put the words on the array.. I was hoping for someone to code it for me.. thanks wierd Link to comment https://forums.phpfreaks.com/topic/256658-a-little-help/#findComment-1315728 Share on other sites More sharing options...
ccherry17 Posted February 8, 2012 Author Share Posted February 8, 2012 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 https://forums.phpfreaks.com/topic/256658-a-little-help/#findComment-1315731 Share on other sites More sharing options...
spiderwell Posted February 8, 2012 Share Posted February 8, 2012 array shift removes the first element, you didnt need to adjust what thorpe gave you Link to comment https://forums.phpfreaks.com/topic/256658-a-little-help/#findComment-1315744 Share on other sites More sharing options...
ccherry17 Posted February 8, 2012 Author Share Posted February 8, 2012 Thank you so much guys! Link to comment https://forums.phpfreaks.com/topic/256658-a-little-help/#findComment-1315746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.