0

I'm referencing to an array and this is only showing the part of string after the slash. How do I show the characters before it also.

#Check for bio
        if ($biosDisplayed == $y) {
            $positionTitle = strpos($bios[$i], " /");
            $positionTitle = substr($bios[$i], 0, $positionTitle);
            echo "<br /><b>Position Title: </b>" . $positionTitle;

            #Company Name
            $position = strrchr($bios[$i], " /");
            echo "<br /><b>Bio: </b>" . strchr($position, " ");
    }
Woovils
  • 3
  • 1
  • Can you give us an example of the value in $bios[$i]? Alternatively, you may try using the explode() function. E.g. $fields = explode(" /", $bios[$i]); – kufudo Feb 14 '13 at 00:35
  • $bios = array("President & CEO / Laganatech","VP of Sales / Elguji Software","VP of Accounting / Drugco Inc.","Programmer / Mobile Solutions, Inc.","Systems Analyst / Sharp Systems"); – Woovils Feb 14 '13 at 00:37

1 Answers1

0

Try this:

if ($biosDisplayed == $y) {
        $fields = explode(" / ", $bios[$i]);

        echo "<br /><b>Position Title: </b>" . $fields[0];
        echo "<br /><b>Bio: </b>" . $fields[1]);
}
kufudo
  • 2,803
  • 17
  • 19