I have this result i want to parse and get Lfam for example in following my result : - object(stdClass)[159]
-
> > public 'PapFamType' =>
-
> > array (size=28)
-
> > 0 =>
-
> > object(stdClass)[164]
-
> > public 'Owner' => string '' (length=0)
-
> > public 'Fam' => string 'CMM' (length=3)
-
> > public 'Lfam' => string 'Couché moderne mat' (length=19)
-
> public 'Ctype' => string 'CM5' (length=3)
-
> public 'Ltype' => string 'Chromomat' (length=9)
-
> public 'Ccoul' => string 'BC' (length=2)
-
> public 'Lcoul' => string 'BLANC' (length=5)
-
> public 'Gramm' => string '400' (length=3)
-
> public 'PoidsM' => string '0' (length=1)
-
>
-
> 1 =>
-
> object(stdClass)[165]
-
> public 'Owner' => string '' (length=0)
-
> public 'Fam' => string 'CMM' (length=3)
-
> public 'Lfam' => string 'Couché Moderne Mat' (length=19)
-
> public 'Ctype' => string 'CM5' (length=3)
-
> public 'Ltype' => string 'Chromomat' (length=9)
-
> public 'Ccoul' => string 'IV' (length=2)
-
> public 'Lcoul' => string 'IVOIRE NATUREL' (length=14)
-
> public 'Gramm' => string '250' (length=3)
-
> public 'PoidsM' => string '0' (length=1)
How I can parse this result ?
I searched, but I didn't found out how I could do it.
Thanks
7 1397
I would use regex and build a function that looks up the key. So something like this: -
<?php
-
$data="lookup.txt";
-
$data=file_get_contents($data);
-
$key="Lfam";
-
function lookup($key,$data){
-
$reg="/(^".$key.")*".$key."(.)*/";
-
print $reg."\n";
-
preg_match_all($reg,$data,$results);
-
print "Results: ".(count($results[0]))."\n";
-
for($i=0;$i<count($results[0]);$i++){
-
print $results[0][$i];
-
print "\n";
-
}
-
}
-
lookup($key,$data);
-
?>
-
http://cp.abelgancsos.com/project.php?id=406
How's that?
how can i put the result in table to get each one
Pull the result of the regex? And each value of the regex result?
You would then use explode($result,"=>") to get the columns.
so i do that: - foreach($quote_infos->Components->Component as $component_index=>$component) {
-
$quote_desc .= ($component_index+1).') '.$component->Title."\n";
-
$quote_desc .= 'Format : '."\t".$component->FmtStd->Width.' x '.$component->FmtStd->Height.' cm'."\n";
-
$quote_desc .= 'Contenu : '."\t".$component->NbSections.' x '.$quote_infos->Quantity.' ex.'."\n";
-
if(isset($component->Paper->Family)) {
-
if(isset($component->Paper->Type) && isset($component->Paper->Color)) {
-
$paper_types = getPaperTypes($component->Paper->Family);
-
$quote_desc .= 'Papier : '."\t".$paper_families[$component->Paper->Family].' - '.$paper_types[$component->Paper->Type].' - '.$component->Paper->Color.' - '.$component->Paper->Weight.' g/m2'."\n";
-
}
-
}
-
}
i need this $quote_desc contains three lines and i need each line stocked in varaible how can i do that in table
Thanks in advance
This looks like you're building the string instead of "parsing" it.
What is it exactly that you're trying to do and what is the full code you have so far?
i need how can i din table contains this result $quote_desc and get each index conatins the line of information
Based on the information that you're giving me, here's SOMETHING what it should look like.
I have a file named lookup.txt (you can name it whatever you want) and I'm pulling this in to a variable called data. The following code assumes that you have a file with the contents and you have a key with the paper name. -
<?php
-
$data="lookup.txt";
-
$data=file_get_contents($data);
-
$key="Lfam";
-
$reg="/(^".$key.")*".$key."(.)*/";
-
preg_match_all($reg,$data,$results);
-
print "Results: ".(count($results[0]))."\n";
-
print "<table id='plain-table'>";
-
print "<tr>";
-
print "<th>Paper Name</th>";
-
print "<th>Paper Type</th>";
-
print "<th>Paper Length</th>";
-
print "<tr>";
-
for($i=0;$i<count($results[0]);$i++){
-
$row=$results[0][$i];
-
$cols=explode("=>",$row);
-
$name=str_replace("public '","",$cols[0]);
-
$name=str_replace("'","",$name);
-
$cols2=explode("' (length=",$cols[1]);
-
$type=str_replace("string '","",$cols2[0]);
-
$length=str_replace(")","",$cols2[1]);
-
print "<tr>";
-
print "<td>".$name."</td>";
-
print "<td>".$type."</td>";
-
print "<td>".$length."</td>";
-
print "</tr>";
-
}
-
?>
-
http://cp.abelgancsos.com/project.php?id=407
PS: By the sound of it, I assume you have a print shop? If so, you can take a look at this database-driven system I built a while back: http://safe.abelgancsos.com/public_p...PaperWorks.zip Sign in to post your reply or Sign up for a free account.
Similar topics
by: sky2070 |
last post by:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')'
in c:\inetpub\wwwroot\session.php on line 19
can anyone tell me what is wrong with this code???
<?
// Define the Session...
|
by: Salim |
last post by:
Hi people, keep getting this errorParse error: parse error, unexpected
T_STRING in order_fns.php line 91. the code is below for the file and
I've indicated line 91
<?php
function...
|
by: chuck amadi |
last post by:
By the way list is there a better way than using the readlines() to
> > >parse the mail data into a file , because Im using
> > >email.message_from_file it returns
> > >all the data i.e reads one...
|
by: praba kar |
last post by:
Dear all,
I want to parse the system functions output
but I couldn't do it. Kindly assist me in this
task.
eg) bytesused = os.system('du -sh /Users/enmail')
if I print this bytesused...
|
by: Ram Laxman |
last post by:
Hi all,
I have a text file which have data in CSV format.
"empno","phonenumber","wardnumber"
12345,2234353,1000202
12326,2243653,1000098
Iam a beginner of C/C++ programming.
I don't know how to...
|
by: Charlie T |
last post by:
hello,
I need a little guidance here...
I am tring to parse out an XML file, but with some restrictions.
here is my XML FILE:
---------XML-----------
<XML>
<Cam name="01">...
|
by: Ehartwig |
last post by:
I recently created a script for user verification, solved my emailing
issues, and then re-created the script in order to work well with the
new PHP 5 that I installed on my server. After...
|
by: Jon Davis |
last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST"
The problem:
// this fails on PST
DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST");
Help?
Jon
|
by: linzhenhua1205 |
last post by:
I want to parse a string like C program parse the command line into
argc & argv.
I hope don't use the array the allocate a fix memory first, and don't
use the memory allocate function like malloc....
|
by: baskarpr |
last post by:
Hi all,
I my program after parsing in SAX parser, I want to write the parse result as an XML file. I want to ensure that there should be no difference between source XML file and parse result xml...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
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,...
| |