How?: PHP-> search html word A, verify if followed by B, if not, cancel. Verify more than once
<p>thanks for being a greatly held community.</p>

<p>I am building an HTML form enhanced with PHP and use some str_replace with a context inputter <code>valuename($substitutable_value)</code> and 2 arrays what will replace all shortcut words that is entered between <code>valuename('text')</code> by its according HTML value... I am a 4 months old developer and work from my cave, lost in the woods so i am much self-learning!</p>

<p>The first use of this code was to replace :icon: in a text by its <code>&lt;img etc... /&gt;</code> - and it became more: a tool to call any html value in text or in forms...</p>

<p>Now i am trying to make "sandwitch" stacks that uses open tags and close tags in 2 different shortcut callers >> <code>:y+</code> and <code>+y:</code> that calls the required chunks to render a youtube embeded video... like, <code>:y+</code> is <code>&lt;object etc...&gt;</code> and <code>+y:</code> is <code>&lt;/object&gt;</code>. All that is needed there is to enter the youtube code between <code>=</code> and <code>?</code> in its link.</p>

<p>The danger involved with my sandwich stack codes is that they comes in pair. I goggled stuff like "php comes in pair" "php verify if A is followed by B and if not, abort" but that's not any Google-friendly sentences... </p>

<p>I need a set of lines that invalidates the <code>:y+</code> if <code>+y:</code> isn't present, i already have a code that invalidate <code>:y++y:</code> if it has nothing between, i need another code that invalidates <code>+y:</code> if it hasnt got <code>:y+</code> previously, and it have to be able to process more than ounce in a same entry. Also, it has to invalidate <code>:y+</code> and <code>+y:</code> if there are spaces or line-returns internally between both but not externally aside both. Something that could verify if the link is valid, at the end, would prevent invalid addresses to be entered.</p>

<p>It will be used in forms on a chatbox. Left into public hands. If somebody enters <code>:y+HAHAIOWNEDYOUANDENTEREDCRAPCHUNKS+y:</code>, it must be invalidated. If someone writes spaces, must be invalidated, forget to enter the youtube code, invalidated, forgets to put or an open tag or a close tag (<code>:y+</code> |or| <code>+y:</code>), dissmissed... But the rest of the message's content must stay intact. Also, the form doesn't support HTML by itself which saves me a lot of sighs!!! :P</p>

<p>Calling a youtube embed in the chatbox works exactly as inserting an emoticon, but as i  said, comes in pair.</p>

<p>Thank's for all further help!</p>

<p>Matt</p>

<p><em><strong></em>_</strong><em>Edit</em><strong><em>_</em>_</strong></p>

<pre><code>&lt;? function A($v1)/*summoning target*/{
    $v2=array('°1°','°2°','°3°');//summon incantation
    $v3=array('code','code2','code3');//incantation result
    $v4=str_replace($v2, $v3, $v1);//build the incantation clockwise from incantation to target
    return $v4//make the incantation castable?&gt;
</code></pre>

<p>That's a simplified version of the exact routine with differant words from original... Words used are inspired from the summonner characters in final fantasy series lol :P
To call upon the values in the motion, it goes like </p>

<pre><code>&lt;?=echo A("Ceci est un bout de texte. On y écrit ce que l'on veut parce qu'on le sens bien. °1° Here is an inserted function, the one located at \"$V3\" And another one, right there: °2° ")?&gt;
</code></pre>

<p>Additionnal codes to make sense are the youtube embed chunks</p>

<pre><code>&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/NmkgH-TENdU?fs=1&amp;amp;hl=fr_FR"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/NmkgH-TENdU?fs=1&amp;amp;hl=fr_FR" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;
</code></pre>

<p>There are two instances of "address" in this code. 
In both instances, the values that doesn't change are <code>http://www.youtube.com/v/</code> and <code>?fs=1&amp;amp;hl=fr_FR</code>. 
The summon I use actually have dissmissed one of both instances as this: </p>

<pre><code>&lt;object width="480" height="385"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/NmkgH-TENdU?fs=1&amp;amp;hl=fr_FR" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;
</code></pre>

<p>What I'd whish to be able to do with my really low knowledge would be to be able to define the value that will vary from a summon to another before or after the code... Say i'd have something like <code>[[value_to_insert(&lt;href="$thisvaluewillnotpropagate"&gt;)]]</code> but i'm quite unsure if such a manipulation is possible at all... (to insert a value that will change upon differant summons withins a block that will always be the same)...........</p>

<p>I whish i have put all that is needed to have the subject well surrounded :)</p>

<p>If i succeed into getting the code that i need, i'll use more functions like the youtube embed in my chat :) Soundclouds embed for example... :) </p>

<p>_<strong><em>Re-edit</em>_</strong>
Indeed, i ask 2 differant questions for the sme problem that would both correct the issue - first solution would be to invalidate :y+ if +y: isnt present,
second one would be to be able to insert a youtube address code before :y: that would make things simpler and scripting lighter :)
In fat, both routines would have me learning something important as both methods has very useful uses for my needs :P</p>
