/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:Cambria; mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin;} hi
我在MS SQL表中有这个值。我已成功使用PHP连接到它并运行查询以获取它并将其抛出为JSON格式。
假设我只有#34;只读"访问或我不想修改数据库中的任何内容,我可以选择删除(包括)'}'之前的所有内容。简而言之,只显示" hi"。
我可以在" SELECT",PHP级别,甚至是JSON输出中修改它。关于如何在每个级别存储数据的快速说明。
非常感谢任何人都可以帮助我。
编辑:很抱歉由于缺乏信息,我编辑了这些信息以包含更多信息。
@ SQL:它的数据类型是" text"。
MSSQL 2012 Field Type: Text
@ PHP:它在数组中。
ie. Array ( [0] => data1 [1] => data2 [2] => /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:Cambria; mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin;} hi )
答案 0 :(得分:1)
<?php
$str='/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:Cambria; mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin;} hi ';
$pos = strpos($str, '}'); //find position of }
echo trim(substr($str,$pos+1)); //extract everything from } to end of string (trim optional)
答案 1 :(得分:0)
$old = '/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:Cambria; mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin;} hi ';
$new = trim(preg_replace( '/.+}([^}]+)$/','\1',$old ));
echo $new;
答案 2 :(得分:0)
如果是TEXT,并且您想在SQL中执行此操作,请转换为VARCHAR(4000)。 例如SELECT LTRIM(RTRIM(SUBSTRING(CONVERT(VARCHAR(4000),colName), CHARINDEX(&#39;}&#39;,CONVERT(VARCHAR(4000),colName))+ 1, LEN(CONVERT(VARCHAR(4000),colName)))))FROM tblName - ZLK 1月27日 2:47
这完美无缺。对于需要超过4000个字符的人来说,这可能是一个问题。