0

Hi all looking for a little help. I've created a site which shows the previous form of soccer teams like so:

Front end result

This works fine and each letter is output by PHP as an image. The problem is that the only way I could get my head round it to work it out was to create a custom field of checkboxes in Wordpress like so:

Backend custom field input

What would probably work better would just to have a textbox on the backend where I could just type in the form like "WLDWW" and then the front end display as necessary.

Problem is that I'm not entirely sure where to start with PHP for it to read each individual letter that I put into the textbox and translate that into the image needed at the front end.

Any ideas?

Thanks in advance

1
  • 1
    These should be radio inputs, not checkboxes. Commented Jun 1, 2017 at 21:55

1 Answer 1

1

Take a look at str_split(). (see here)

$string = "WLWLLW";
$result = str_split($string);

This will output:

Array
(
[0] => W
[1] => L
[2] => W
[3] => L
[4] => L
[5] => W
)   

Then you can iterate through the array and display as needed, if you want to use PHP. Of course, I don't know how you've implemented it exactly or how it uses Wordpress, so you may have to make some adjustments as needed.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, this helps, thanks very much. Basically I have 3 images which represent "Win - Lose & Draw", win is "/images/w.png - lose is "/images/l.png etc, so when a letter is chosen in a wordpress custom field it outputs that image. Your example puts me on the right track though I would need to research to see how to take each array and translate that into the image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.