top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Finding the Middle elements of a String in PHP

+1 vote
101 views

Let's say the string is "ram,shyam,seeta,geeta" (not an array just a text string)

I see that I can use these (strpos)

$findme = ',';
$pos = strpos($this1, $findme);
$pos2 = strripos($this1, $findme);

$showfirst = substr($this1, 0, $pos); 
$showlast = substr($this1, $pos2+1, 9999 ); 
posted May 11, 2014 by Rameshwar

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

+2 votes

Not sure what you are trying to do? If you're looking to get the words out of the string, just explode it into an array and get the elements you want from the array.

$str = ""ram,shyam,seeta,geeta";
$ary = explode(',',$str);
answer May 11, 2014 by Arjuna
0 votes

$str = ""ram,shyam,seeta,geeta";
$ary = explode(',',$str);

answer May 18, 2014 by Vrije Mani Upadhyay
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...