Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Exploding on character(s) that can NEVER be user-defined... How?
    text
    copied!<p>Ok, am trying to find a character or group of characters, or something that can be used that I can explode from, since the text is user-defined, I need to be able to explode from a value that I have that can never be within the text.</p> <p>How can I do this?</p> <p>An example of what I'm trying to do...</p> <pre><code>$value = 'text|0||#fd9||right'; </code></pre> <p>Ok,</p> <p>text is something that should never change in here. 0, again not changeable <code>#fd9</code> is a user-defined string that can be anything that the user inputs... and right sets the orientation (either left or right).</p> <p>So, the problem I'm facing is this: How to <code>explode("||", $value)</code> so that if there is a || within the user-defined part... Example:</p> <pre><code>$value = 'text|0||Just some || text in here||right'; </code></pre> <p>So, if the user places the || in the user-defined part of the string, than this messes this up. How to do this no matter what the user inputs into the string? So that it should return the following array:</p> <pre><code>array('text|0', 'Just some || text in here', 'right'); </code></pre> <p>Should I be using different character(s) to explode from? If so, what can I use that the user will not be able to input into the string, or how can I check for this, and fix it? I probably shouldn't be using || in this case, but what can I use to fix this?</p> <p>Also, the value will be coming from a string at first, and than from the database afterwards (once saved).</p> <p>Any Ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload