Isolating a chunk of text using php


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Isolating a chunk of text using php
# 1  
Old 03-23-2016
Isolating a chunk of text using php

greetings,
i'll start by stating; i am NOT looking for the EXACT syntax to my query but a simple yes or no of its possibility. and if you're feeling generous maybe the php function(s) that i'd use as a jump start. i could use bash but i really want to take a shot at doing this with php. the following output:

Code:
Online help is available at
http://reference.wolfram.com/network

MathLM Version: 10.0
MathLM Server: localhost.local
Date: Tuesday, March 22 2016 15:57:04



License Usage Summary:

                        License Total   Total
Program                 Class   in Use  Authorized
--------------------------------------------------
Mathematica             B            0           2
MathKernel              B            0           2
Sub Mathematica         B            0          16
Sub MathKernel          B            0          16

Licenses in Use:
                             License
Program              Version Class   Username      Hostname            Duration
-------------------------------------------------------------------------------

i need to isolate everything that is between the line of hyphens under the first occurrence of "Program" and the next empty/blank line so i can tinker with how i'm going to process those lines. is there a php function that will do that with relative ease?
thanks in advance.

---------- Post updated 03-23-16 at 10:03 AM ---------- Previous update was 03-22-16 at 01:02 PM ----------

for those looking to accomplish something similar here goes. i scammed the following function online and the above output as $response2. i then used the function and a few other commands to get what i needed:

Code:
function get_string_between($string, $start, $end){
        $string = ' ' . $string;
        $ini = strpos($string, $start);
        if ($ini == 0) return '';
        $ini += strlen($start);
        $len = strpos($string, $end, $ini) - $ini;
        return substr($string, $ini, $len);
}

$feature_line = get_string_between($response2, '--------------------------------------------------', 'Licenses');
$feature_line = trim($feature_line);
echo $feature_line;
Mathematica             B            0           2
MathKernel              B            0           2
Sub Mathematica         B            0          16
Sub MathKernel          B            0          16

at this point i can used i can probably use preg_split, substr and trim to divide and conquer.

Last edited by crimso; 03-22-2016 at 02:19 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Isolating & Counting IP from log file

Dear Community, today my website was under attack for several hours. 2 specific IPs make a tons of "get requests" to a specific page and apache server goes up and down. Now the problem is solved because I put in firewall blacklist these IPs, but I took a lot of time to analyze the apache log to... (6 Replies)
Discussion started by: Lord Spectre
6 Replies

2. Shell Programming and Scripting

Grabbing a chunk of text from a file

Hi, I have a Report.txt file. Say the contents of this file are : 1 2 3 4 5 7 df v g gf e r dfkf lsdk dslsdklsdk Report Start: xxxxxxdad asdffsdfsdfsdfasfasdffasdf sadfasdfsadffsfsdf Report End. sdfasdfasdf sdfasfdasdfasdfasdfasdf sadfasdfsdf I need to grab from Report Start... (3 Replies)
Discussion started by: mrskittles99
3 Replies

3. UNIX for Advanced & Expert Users

chunk server implementation

How unix file can be put in the hash table and how to write a program in which the chunk server acts as a client and server . Can you give me a comprehensive idea of implementation. (0 Replies)
Discussion started by: kswapnadevi
0 Replies

4. Shell Programming and Scripting

Delete chunk of text if contains certain strings

Using awk how to delete chunk of text if it contains certain strings? As in the following, delete a reference chunk, i.e. everything from <reference attribute = "value"> to </reference> inclusive, if within it "Group ID" value is 7 or 96 or 103 or 1005. <reference attribute = "value"> ... (3 Replies)
Discussion started by: pioavi
3 Replies

5. Shell Programming and Scripting

print chunk of lines only if there is a pattern match in between them

Hi All, Please find the sample file below: NAME ID NUMBER -------------------------------------------------------------------------------------------------- --------- abcdefgheija;lksdf ... (13 Replies)
Discussion started by: niel.verty
13 Replies

6. UNIX for Dummies Questions & Answers

Isolating Stat Results

i'm trying to isolate the results from the stat command to just the file name and the size. I got as far as: stat *.jpg | grep Size How can I isolate the size and the file name? (3 Replies)
Discussion started by: jvpike
3 Replies

7. Shell Programming and Scripting

Isolating a specified line - awk grep or somthing else?

I'm trying to isolate attached hard drives that auto-mount to /media so that I can use them as variables in a bash script... so far I'm here: variable=$(ls /media | grep -v cdrom ) This lists all the connected drives, each on it's own line and doesn't list anything I don't want (cdrom... (2 Replies)
Discussion started by: Starcast
2 Replies

8. Shell Programming and Scripting

Isolating the Month in Perl

munt=`date '+%m` will isolate the month in digit form 02 = Feb Trying to get the same out of perl just cant see it $stimx = localtime($^T); print ((split/ /,$stimx)); (4 Replies)
Discussion started by: popeye
4 Replies

9. Shell Programming and Scripting

Surrounding a chunk of code by #ifdef and #endif

Hello the great gurus :) I'm quite new to this, so perhaps I'm asking a simple and trivial question (which is good, because you'll answer for sure :)))) Anyway. I have an amount of *.c files (about 100), and what I want to do, is to surround a specific function call with #ifdef and #endif. ... (6 Replies)
Discussion started by: xxxaxa
6 Replies

10. UNIX for Dummies Questions & Answers

offset - informix chunk

Hello all, I am trying to add chunks to my informix dataspace. I have one dataspace ( the rootdbs ) and the new chunk is a raw device. Precisely slice1 on my new external harddisk. The question is, what should be the offset value. The document says, the offset is used by the engine to... (1 Reply)
Discussion started by: shibz
1 Replies
Login or Register to Ask a Question