473,513 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I get X (or another value) from this string "asdfsadf[www]X[/www]"

How can I get X (or another value) from this string
"asdfsadf[www]X[/www]",
basically i want to get what ever is in between the [www] tags and
place them in a variable called $www , can anyone help?

Dec 20 '05 #1
6 1639
You could probably use the strrpos($string, "[www]") to get the position
of the "X" data. Then use the substr($string, $position_start,
$position_end) function to create your $www variable...

Let me know if that doesn't help.

also, check these pages out :)

http://us2.php.net/manual/en/function.substr.php
http://us2.php.net/manual/en/function.strrpos.php

Michael wrote:
How can I get X (or another value) from this string
"asdfsadf[www]X[/www]",
basically i want to get what ever is in between the [www] tags and
place them in a variable called $www , can anyone help?

Dec 20 '05 #2
Thanks, this looks like it will work fine, I don't have time to try it
now but I will have a look at it later. I would be interested to know
if there is a simpler way to do it though.

Dec 20 '05 #3
a less efficient, but perhaps easier to read or more flexible method
would be something like:
ereg('\[www\](.*)\[/www\]', $text, $arr);
$variable_inside_www = $arr[1];

Dec 22 '05 #4
I need a solution that will loop until all of the [www][/www] tags in
string into an array and from there on i have everything sorted.

Dec 22 '05 #5
Michael wrote:
I need a solution that will loop until all of the [www][/www] tags in
string into an array and from there on i have everything sorted.


If you want to go the regular expression way, have a look at
preg_match_all().

If you want to go the strpos(), substr() way, remember the third
parameter to the strpos() function.

Dec 22 '05 #6
with ereg, you can do something similar to this:

while (ereg('\[www\](.*)\[/www\](.*)', $text, $arr))
{
$variables_inside_www[] = $arr[1];
$text = $arr[2];
}

Dec 23 '05 #7

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

Similar topics

3
7404
by: oliver.wulff | last post by:
Does there exist a class similar to a hashtable which provides a key-value pair collection. The key and the value has to be a string?
1
1396
by: Surya | last post by:
I'm using Microsoft.Project.OLEDB.9.0 provider with a datareader to read data from a .mpp file (Microsoft Project plan) from ASP.NET The problem is All the STRING values, the datareader returns, do...
9
54149
by: Henrik | last post by:
In Java you can write something like this. Does anyone know how to do this in javascript? "byte b=Integer.parseInt(int value or String).byteValue;"
4
1367
by: Mrozu | last post by:
Hi I need function which can show me value of string only TO seted sign. For example i have string x="Hello, people" and i need function which show me string to ",", in this situation...
6
6084
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
4
1513
by: Max80 | last post by:
Hi Everyone, I have a double value (e.g. 2.00) which I would like to convert to string. Simply returning the value using the .ToString() method trims the 0s after the decimal...
2
7000
by: pnsreee | last post by:
Hi All, I have the following code. The array @sub_data will contain integers or a string"NO". I have to validate if the array contain integer. If it contain "NO" then no need to validate. ...
1
1171
by: hameeduddinasim | last post by:
Hi I am trying to get the value from string into string it is working fine in VB.Net but i facing problem in C# VB Code Dim COABANKS() As String Dim SR3 As StreamReader =...
0
1382
by: visweswaran2830 | last post by:
Hi, i want to concat int value with string val in vc++.. eg: for(ii=0;ii<100;ii++) { strcpy(fname,"Img"); strcat(fname,CString(ii));
0
7160
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
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
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
7525
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...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.