English 中文(简体)
Edit String in PHP before being supplemented
原标题:Edit String in PHP before being added
  • 时间:2011-11-23 14:46:53
  •  标签:
  • php
  • replace

我有一个书写XML档案的制度。

问题是,在XML文件中,我不可能有这一编号:&

在代码中,我需要将这一编号改为&

问题在于我有一套指示,我不想应用一种功能,取代我所描述的埃韦·斯廷里的这个象征。

例如:

$stringData ="<?xml version="1.0" encoding="UTF-8"?>
";
$stringData .="<ingrooves_import xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd" schema_version="1" schema_revision="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd">
";
$stringData .= "<album>
";
$stringData .= "<title>".$albumTitle."</title>
";
$stringData .= "<label_reference>LA0001</label_reference>
";
$stringData .= "<performer>".$MainArtist."</performer>
";
$stringData .= "<catalog_number>".$CatalogueNumber."</catalog_number>
";
$stringData .= "<upc>".$UPC_EAN_JAN."</upc>
";
$stringData .= "<release_date>".$releaseDate."</release_date>
";
$stringData .= "<copyright>".$DigiDistYear."</copyright>
";

我的法典中还有许多美元。 因此,你可以理解,我不想申请每笔记本,代之以代号。

我想找到一种办法,告诉该守则,对于任何美元升值变量,就任何内容而言,该笔数额将碰到,那么它必须替换<代码>和amp; with &amp;

Is there a way of doing it?

In few words, the code should do so:

从现在起,你将在可变数的加固元件内碰到每个内容,请修改<代码>和>; with &amp;。 每一次,你都会遇到这一编号。

Please help me!

Thanks

最佳回答

At the end of the script, when you finished adding code to the string, add the following:

$stringData = str_replace ( & , &amp; ,$stringData);

你们也可以定期表达,但这样做会带来:

问题回答

这可能太远了,但仅使用http://de3.php.net/manual/en/Function.str-replace.php” rel=“nofollow”>。 在建设你的XML产出之后?

$stringData = str_replace( & , &amp; ,$stringData);

注:

这将取代现有的<代码>&amp;至&amp;,从而确保你在使用这一代码之前不会有<代码>&amp;。

采用这一方法,并处以罚款:

$stringData = str_replace( & , &amp;$stringData);

我不清楚我是否正确理解你的问题。

基本上,在派任结束时,你替换了所有的沙土;在座标内安装和安装;

$myString = "this is a test & you &&& can & see";
$newString = str_replace( & ,  &amp , $myString);
echo $newString;

在新的变量中,你可以看到所有和安放,现在重新铺设;

由于浏览器将展示所有的“灯”和“灯”等,你无法看到结果。

你们需要研究该守则或在终点站测试该守则。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签