473,396 Members | 2,010 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.

Finding variables in a string?

11
Ok, heres my problem. I want to be able to read other php files and get each line, which i can do by $lines = file("file.php");. now the problem is i want to search each index of the $lines array and check for any php variables. all the variables will start with $ so i could try explode("$", $lines[$x]);, but how would i cut the extra text like commands etc off of the end of the variable name? Any help would be GREATLY appreciated. thanks alot!
Oct 19 '07 #1
4 1118
MarkoKlacar
296 Expert 100+
Hi BaKo,

sound like you could do this with a string tokenizer, but could you post an example of what the read line look like when you explode, and what exactly you want it to look like when you're finished with it.

Cheers
Oct 19 '07 #2
BaKo
11
well I dont really care about explode or how anything else looks/works, as long as the end result is an array with all the variables. any clues?
Oct 20 '07 #3
MarkoKlacar
296 Expert 100+
Hi BaKo,

could you post an example of what of want should happend? To give me a better picture of how I can help you.

Cheers
Oct 22 '07 #4
Atli
5,058 Expert 4TB
Hi BaKo.

As you know, variable names start with $ followed by a letter, and end with a non alpha-numeric character (excluding underscore '_'). So... you could find each $ in the text, and the next non alpha-numeric character after that and use substr() to fetch the variable name.

Note that a $ followed by anything other than a letter is an invalid variable name so you may also want to check for that.
Oct 23 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: hokiegal99 | last post by:
Hi, I have a working Python script that renames files that don't currently have PC based file extensions. For example, if there is a MS Word file that does not have '.doc' on the end of it, the...
2
by: Steve | last post by:
Hi, I have a very long string, someting like: DISPLAY=localhost:0.0,FORT_BUFFERED=true, F_ERROPT1=271\,271\,2\,1\,2\,2\,2\,2,G03BASIS=/opt/g03b05/g03/basis,...
13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
5
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the...
7
by: ralphNOSPAM | last post by:
Is there a PHP script that can find unused variables? I'd like to 'clean up' my scripts. Thanks...
5
by: Mike | last post by:
Hi I've written a module to find the first occurrence of a record in a query (that is my forms datasource) that matches four specified criteria. No matter what I try it doesn't seem to find ...
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
21
by: Tom Gur | last post by:
Hi, It's seems that csh and tcsh acts a bit different when handling special characters in quotes. i.e: if i'll supply my program with the following arguments: -winpath "c:\\temp\\" tcsh will...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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...
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.