How does the contents of the string replace the contents of the array?

Source: Internet
Author: User
Like I have an array
$a =array (0=>SDFS,1=>333,2=>444,3=>SADFSAF)

Then I have a string with the string content as follows:

This afternoon, reporters from the third Chinese stone exhibition and Yellow Wax stone Cultural Exposition news conference, this year's Yellow wax stone cultural exposition will be on November 8 in Yingtan June Rong International Glasses city opened [ABC]2[/ABC] exhibition, to November 16 curtain. Activity period [ABC]1[/ABC] will be exhibition from all over the country of the odd stone, fossils, Ore crystal, gem and its crafts, root, ceramics, antiques, paintings, collectibles. For the active Stone Expo atmosphere, gathering stone Expo popularity, during the exhibition, organizers also arranged calligraphy pen, star concert, Beer festival, spectacle show and other cultural activities.

In order to facilitate visitors to visit, Bus 21 road during the stone Fair [ABC]7[/ABC] on the driving route to make adjustments?? From the railway station, take the station River Road to the west road, and then directly along the Eagle West Avenue to June Rong international yellow wax stone antique big market. At the same time, the organizer also arranges daily car [abc]4[/abc] in Antique street back door, will visit the Stone Fair audience to the exhibition scene.

The length of the array, and the number of the [ABC]*[/ABC] tag inside the string is necessarily equal.
Now I want to replace the $a[0 in the array with the order in which [ABC]*[/ABC] appears in the string: the value of $a [3].
Also, how do I count [abc]*[/abc] occurrences??

That
Replace [ABC]2[/ABC] with the value of $a[0] SDFs. ,
Replace [ABC]1[/ABC] with the value of $a[1] 333
Replace [ABC]7[/ABC] with the value of $a[2] 444
Replace [ABC]4[/ABC] with the value of $a[3] Sadfsaf

Description
[ABC]2[/ABC] This [ABC]*[/ABC] must be a positive integer, without other special characters, where there is no regularity,




Reply to discussion (solution)

$s =<<< txt this afternoon, reporters from the third Chinese stone exhibition and Yellow Wax stone Cultural Exposition news conference, this year's Yellow wax stone cultural exposition will be on November 8 in Yingtan June Rong International Glasses city opened [ABC]2[/ABC] exhibition, to November 16 curtain. Activity period [ABC]1[/ABC] will be exhibition from all over the country of the odd stone, fossils, Ore crystal, gem and its crafts, root, ceramics, antiques, paintings, collectibles.  For the active Stone Expo atmosphere, gathering stone Expo popularity, during the exhibition, organizers also arranged calligraphy pen, star concert, Beer festival, spectacle show and other cultural activities. In order to facilitate visitors to visit, Bus 21 road during the stone Fair [ABC]7[/ABC] on the driving route to make adjustments?? From the railway station, take the station River Road to the west road, and then directly along the Eagle West Avenue to June Rong international yellow wax stone antique big market. At the same time, the organizer also arranges daily car [abc]4[/abc] in Antique street back door, will visit the Stone Fair audience to the exhibition scene. TXT; $a = Array (0 = ' SDFs ', 1 = ' 333 ', 2 = ' 444 ', 3 = ' Sadfsaf '), foreach ($a as $v) $s = preg_replace ("/\[ab c\]\d+\[\/abc\]/", $v, $s, 1); Echo $s;
This afternoon, reporters from the third Chinese stone exhibition and Yellow Wax stone Cultural Exposition news conference, this year's Yellow wax stone cultural exposition will be on November 8 in Yingtan June Rong international Glasses City Open SDFs exhibition, to November 16 curtain. Activity period 333 will be exhibition from all over the country of strange stone, fossils, Ore crystal, gem and its crafts, root, ceramics, antiques, calligraphy, collectibles. For the active Stone Expo atmosphere, gathering stone Expo popularity, during the exhibition, organizers also arranged calligraphy pen, star concert, Beer festival, spectacle show and other cultural activities.

In order to facilitate the audience to visit, Bus No. 21 bus during the Stone Expo 444 on the driving route to make adjustments?? From the railway station, take the station River Road to the west road, and then directly along the Eagle West Avenue to June Rong international yellow wax stone antique big market. At the same time, the organizer also arranges daily car sadfsaf in Antique street back door, the visitors to the stone Fair will be sent to the exhibition site.

$s =<<< txt this afternoon, reporters from the third Chinese stone exhibition and Yellow Wax stone Cultural Exposition news conference, this year's Yellow wax stone cultural exposition will be on November 8 in Yingtan June Rong International Glasses city opened [ABC]2[/ABC] exhibition, to November 16 curtain. Activity period [ABC]1[/ABC] will be exhibition from all over the country of the odd stone, fossils, Ore crystal, gem and its crafts, root, ceramics, antiques, paintings, collectibles.  For the active Stone Expo atmosphere, gathering stone Expo popularity, during the exhibition, organizers also arranged calligraphy pen, star concert, Beer festival, spectacle show and other cultural activities. In order to facilitate visitors to visit, Bus 21 road during the stone Fair [ABC]7[/ABC] on the driving route to make adjustments?? From the railway station, take the station River Road to the west road, and then directly along the Eagle West Avenue to June Rong international yellow wax stone antique big market. At the same time, the organizer also arranges daily car [abc]4[/abc] in Antique street back door, will visit the Stone Fair audience to the exhibition scene. TXT; $a = Array (0 = ' SDFs ', 1 = ' 333 ', 2 = ' 444 ', 3 = ' Sadfsaf '), foreach ($a as $v) $s = preg_replace ("/\[ab c\]\d+\[\/abc\]/", $v, $s, 1); Echo $s;
This afternoon, reporters from the third Chinese stone exhibition and Yellow Wax stone Cultural Exposition news conference, this year's Yellow wax stone cultural exposition will be on November 8 in Yingtan June Rong international Glasses City Open SDFs exhibition, to November 16 curtain. Activity period 333 will be exhibition from all over the country of strange stone, fossils, Ore crystal, gem and its crafts, root, ceramics, antiques, calligraphy, collectibles. For the active Stone Expo atmosphere, gathering stone Expo popularity, during the exhibition, organizers also arranged calligraphy pen, star concert, Beer festival, spectacle show and other cultural activities.

In order to facilitate the audience to visit, Bus No. 21 bus during the Stone Expo 444 on the driving route to make adjustments?? From the railway station, take the station River Road to the west road, and then directly along the Eagle West Avenue to June Rong international yellow wax stone antique big market. At the same time, the organizer also arranges daily car sadfsaf in Antique street back door, the visitors to the stone Fair will be sent to the exhibition site.


Too bull B, master.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.