473,574 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ


Here is the sample text (( http://starkom.com/bill20050820_000000 ))

wanted to know if there is some other function like explode to split
the = sign in each array

Aug 28 '05 #1
7 1912
voipcanada schrieb:
Here is the sample text (( http://starkom.com/bill20050820_000000 ))

wanted to know if there is some other function like explode to split
the = sign in each array

perhaps split is the function you are looking for.

However if you don't want to use php: man awk.


Aug 28 '05 #2
ok thanks ,,,,,,

Aug 28 '05 #3
On Sun, 28 Aug 2005 14:01:19 -0700, voipcanada wrote:
Here is the sample text (( http://starkom.com/bill20050820_000000 ))

wanted to know if there is some other function like explode to split
the = sign in each array

This is not going to work with the simple split. You'll first have to
split using ",\s+" and then, in turn, to split each array element of the
resulting array using "=" as delimiter. The code would look like this:

$fh = fopen("/tmp/myfile.txt", "r");
while (!feof($fh)) {
$buff = fgets($fh, 4096);
$line = preg_split("/,\s+/", "DATE=$buff ");
foreach($line as $elem) {
$pair = preg_split("/=/", $elem);
@$parsed[$pair[0]] = $pair[1];
print_r($parsed );
$parsed = array();

The output look like this:

[DATE] => Sat Aug 20 18:20:20 2005
[HOST] =>
[SRC-NUMBER-IN] => 8565686628
[DST-NUMBER-IN] => 888#8565487318
[SRC-NUMBER-OUT] => 8565686628
[DST-NUMBER-OUT] => 888#8565487318
[SRC-NUMBER-BILL] => 8565686628
[DST-NUMBER-BILL] => 888#8565487318
[SRC-IP] => 98
[DST-IP] => :1720
[RECORD-ID] => 1124534625-61
[SETUP-TIME] => 18:19:38.000 GMT Sat Aug 20 2005
[CONNECT-TIME] => 18:19:38.000 GMT Sat Aug 20 2005
[DISCONNECT-TIME] => 18:20:20.000 GMT Sat Aug 20 2005
[SRC-BYTES-IN] => 126957
[DST-BYTES-IN] => 18276
[SRC-BYTES-OUT] => 18308
[DST-BYTES-OUT] => 126494
[QOS] => 11
[SRC-CODEC] => g729
[DST-CODEC] => g729
[CALLID] => 083b3cbf10fb11d a8ba0837c360ba9 85
[CONFID] => 083b3cbf10fb11d a8b9e837c360ba9 85


That is, I believe, what you want to achieve.


Aug 29 '05 #4
On Sun, 28 Aug 2005 23:06:58 +0200, Joachim Weiß wrote:
However if you don't want to use php: man awk.

No need for lame tools like awk. PHP can do it perfectly well.


Aug 29 '05 #5
thank you works really well ,, kind regards

Sep 13 '05 #6

many i ask you one more question ,,, $buff = fgets($fh, 4096); what
does 4069 mean ,,
Is it for number of lines to import ,, thanks for your responce

Sep 13 '05 #7
On 2005-09-13, voipcanada <vo********@gma il.com> wrote:

many i ask you one more question ,,, $buff = fgets($fh, 4096); what
does 4069 mean ,,

rtfm http://www.php.net/fgets

Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be >
Sep 13 '05 #8

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

Similar topics

by: Rob Gudgeon | last post by:
Hi Is it possible to explode a string into an array using more than one separator? I have database records that contain several values, mostly split by semi-colons but some older records are split by comma. It's obviously no hassle if I have to explode twice but it'd be nice if I could do it with one line... cheers, Rob
by: Mark | last post by:
Hello, I have been searching for a reason for this behavior but no solution so I figured I would ask. Basically I have a web page that displays data in a database to the user for updates/deletion/addition. For each data field ont he web page I put the data from the database in the field name with teh field name and data seperated by a...
by: William Krick | last post by:
I have a string containing concatenated ascii "records" that are each terminated by '\n'. For testing purposes, I construct sample data like this... $mystring = "a|b|c|d\n"."e|f|g|h\n"."i|j|k|l\n"."m|n|o|p\n"; I want to use explode() to put the records into an array like this...
by: torpecool | last post by:
Hello Everyone, I have a situation that I just cannot wrap my head around. I would appreciate any ideas or suggestions. I am trying to parse and load a tab delimited file into a mysql database. The file is generated by a scientific instrument. One file contains the records of several people. Each person's information is in 3...
by: FFMG | last post by:
Hi, I need the php equivalent of explode in one of my app. I read a very big file and "explode" each line to fill a structure. The reading of the file, 19Mb, (I will also need to streamline the way I read each line I guess), takes about 10 seconds. But when I 'explode' each line the process takes about 140 seconds. This is what I have...
by: Joe | last post by:
I have a 'random quotes' plugin that I use which reads tab delimited quotes from multiple text files in a directory, and then randomly displays one. Each text file contains multiple lines, each listing a person and a quote, separated by a tab, and each file is based around a topic. I use fopen and fread to suck in all the text, and then...
by: k04jg02 | last post by:
Python has a nifty operator that will take a container and pass its elements as function parameters. In Python you can make a list like so: x = Then you can say: f(*x)
by: tolkienarda | last post by:
hi everyone i am getting a bunch of values from a form via post all of the information that this question deals with is from series of check boxes below is the code that creates the check boxes the logic behind it is it gets a bunch of listing from the database and if $group is not null then the first check box is checked and a second created...
by: Jack | last post by:
I would like to Explode a string into an array that does not begin at 0 but I can't get it to work. For example: $MyInfo = array(1 =27,68,31,19,40); will result in $MyInfo = 27 ... $MyInfo = 40 But, I'd like to process a string: "27,68,31,19,40" such that it would get the same result. I tried:
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...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 we have to send another system
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.