Note that there are some explanatory texts on larger screens.

plurals
  1. POFind/replace after PHP code has been applied
    primarykey
    data
    text
    <p>I'm trying to build a PHP form that outputs custom JSON code.</p> <p>Take a look: <a href="http://s194239704.onlinehome.us/bcembed/" rel="nofollow">http://s194239704.onlinehome.us/bcembed/</a></p> <p>The JSON code output that the app creates is wrong. I need to do a search and replace to remove some of the commas.</p> <p>The (partial) source code looks like this:</p> <pre><code>{ &lt;!-- ALBUM ART --&gt;&lt;span &lt;?php if($artdisplay!="block") echo "style=\"display:none;\""; ?&gt;&gt;"art": { "x": &lt;?php echo $artx; ?&gt;, "y": &lt;?php echo $arty; ?&gt;, "w": &lt;?php if($artsize=="small") {echo "100";} elseif($artsize=="large") {echo "150";} ?&gt;, "h": &lt;?php if($artsize=="small") {echo "100";} elseif($artsize=="large") {echo "150";} ?&gt;, "show": true },&lt;/span&gt; &lt;!-- MAINTEXT --&gt;&lt;span &lt;?php if($maintextdisplay!="block") echo "style=\"display:none;\""; ?&gt;&gt;"maintext": { "x": &lt;?php echo $maintextx; ?&gt;, "y": &lt;?php echo $maintexty; ?&gt;, "w": &lt;?php echo $maintextw; ?&gt;, "h": &lt;?php echo $maintexth; ?&gt;, "show": true, "styles": { "fontSize": "&lt;?php echo $maintextfontsize; ?&gt;", "textAlign": "&lt;?php echo $maintextalign; ?&gt;", &lt;?php if($maintextbold=="bold") echo "\"fontWeight\": \"" . $maintextbold . "\","; ?&gt; &lt;?php if($maintextitalic=="italic") echo "\"fontStyle\": \"" . $maintextitalic . "\","; ?&gt; }},&lt;/span&gt; } </code></pre> <p>I want to run the search/replace after the PHP is applied. I tried wrapping the whole thing in a JavaScript search/replace, because I thought the PHP would run before the Javascript code. But nothing happened.</p> <p>Can you tell I'm in over my head? Half-assed copy and pasting can only get me so far...</p> <hr> <p><strong>Edit: I didn't know about json_encode.</strong> It seems to be working, but I ran into another snag. I want to have this as the output:</p> <pre><code>"currenttime": { "x": 0, "y": 0, "w": 30, "h": 30, "show": true, "styles": { "fontSize": "13", "fontWeight": "bold", "fontStyle": "null", "textAlign": "center" } } </code></pre> <p>And this is the code I'm trying to use:</p> <pre><code>$jsonData['currenttime'] = array( 'x' =&gt; $currenttimex, 'y' =&gt; $currenttimey, 'w' =&gt; $currenttimew, 'h' =&gt; $currenttimeh, 'show' =&gt; $currenttimedisplay=="block" ? true : false, ['styles'] = array( 'fontSize' =&gt; $currenttimefontsize, 'fontWeight' =&gt; $currenttimebold, 'fontStyle' =&gt; $currenttimeitalic, 'textAlign' =&gt; $currenttimealign ) ); </code></pre> <p>It's like I need a sub-array for the styles... what's the right way to format this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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