473,563 Members | 2,662 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 1648
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_insid e_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_insi de_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
7406
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
1401
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 not end properly. I mean, suppose the value its suposed to return is "surya".. But instead it returns "sury The length of this string is around 256...
9
54162
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
1368
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 Hello, other example
6
6093
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 more minutes. 'REMOVE DUBLICATED VALUE FROM ARRAY +++++++++++++++++ Dim col As New Scripting.Dictionary Dim ii As Integer = 0
4
1521
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 point. I know that its is possible by doing the following double d1 = 2.00; string strValue; strValue = d1.ToString("#,###.00") However the...
2
7007
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. for ($i=1;$i<10;$i++) { Tie::CheckVariables->on_error(sub{print "ERROR!"}); tie my...
1
1181
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 = File.OpenText(path)
0
1387
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
7659
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7634
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7945
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6244
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5481
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.