Home › Forums › Front-end Issues › PHP, explode() and field() › Reply To: PHP, explode() and field()
Assuming that you have the complete string Field : ABC|DEF|GHI|JKL|MNO
:
$data = explode( ':', get_field('MyField' );
$parts = explode( '|', $data[1] );
foreach($parts as $k=>$part){
if($k && ($k < count($parts) ) ) echo ' / ';
echo $part;
}
… but if your field string is only ABC|DEF|GHI|JKL|MNO
, you can leave out the first explode step:
$parts = explode( '|', get_field('MyField' );
foreach($parts as $k=>$part){
if($k && ($k < count($parts) ) ) echo ' / ';
echo $part;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.