473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

change some characters of one String

Hello
Whit this:
<?php echo str_replace ( "\r", "<br/>", $arr[texto]) ; ?>
i replace the \r with the <br/>

but i must analyze one String and see if there is into the String:
1, 2, 3, 4, 5, 6, 7, 8, 9, 0
and replace those characters with <br/>

can anybody help me?
thanks
Jul 16 '05 #1
1 10092
"[XaToA]" <gr****************@latinmail.com> wrote in message
news:bf************@ID-59646.news.uni-berlin.de...
Hello
Whit this:
<?php echo str_replace ( "\r", "<br/>", $arr[texto]) ; ?>
i replace the \r with the <br/>

but i must analyze one String and see if there is into the String:
1, 2, 3, 4, 5, 6, 7, 8, 9, 0
and replace those characters with <br/>

can anybody help me?
thanks


First, make sure there's a space in your "br" tag: <br /> not <br/>.
Netscape used to have some issues when you left out the space.

Look up the Regular Expression functions in the manual. Here's how you
could accomplish your current task:

<? echo preg_replace('/[0-9]/', '<br />', $arr['texto']); ?>

Of course, this will replace any digit with a <br /> tag. If you had
something like "25" in your string, it would be replaced with "<br /><br />"
If you want to be more sophisticated, you could set the digit on a word
boundary:

preg_replace('/\b[0-9]\b/', '<br />', $arr['texto']);

This would replace any single digit with a <br /> tag.

As you can see, the specifications of your problem must be very specific if
you want it to behave like you expect. Learn how to use regular expressions
and your life will be much easier.

HTH,
Zac

Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sigi | last post by:
Hi guys. I am new member in this group. I am also new to Visual C++. I am developing a new system. I have a password to enter the system. The user should have a choice to change his/her password...
5
by: Steve | last post by:
I need a way to programatically change the width of a textbox to display all the data knowing the font, font size and number of characters. Does any oone know of a reference somewhere ot a way to...
19
by: chee.k.cheng | last post by:
Hi, I'm wondering if it is possible to change the starting address of a structure element. For example, I have the following structure: struct demo { char digit; char alpha; } an;
13
by: sonald | last post by:
Hi, Can anybody tell me how to change the text delimiter in FastCSV Parser ? By default the text delimiter is double quotes(") I want to change it to anything else... say a pipe (|).. can anyone...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
14
by: Zoro | last post by:
My task is to read html files from disk and save them onto SQL Server database field. I have created an nvarchar(max) field to hold them. The problem is that some characters, particularly html...
11
by: Freddy Coal | last post by:
Hi, I'm trying to read a binary file of 2411 Bytes, I would like load all the file in a String. I make this function for make that: '-------------------------- Public Shared Function...
26
by: Protoman | last post by:
I've written this program that simulates a 36 character, 10 rotor reciprocal rotor cipher, w/ a plugboard. Any way I can make the plugboard function more compact and/or be able to change the...
7
by: jeddiki | last post by:
Hi, I am using a function called htmlwrap() which states that it does NOT add a "<br>" to the 70 character line so that it forces a line wrap. ( the script safely wraps long words without...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.