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 1407
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 class
class Session
{
// Define the properties:
|
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 process_card($card_details)
{
// connect to payment gateway or
// use gpg to encrypt and mail or
// store in DB if you really want to
|
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 entire line from the file , headers as
well
> > >as just the desired body messages .
> > >
> > >fp = file("/home/chuck/pythonScript/testbox")
> > >mb = mailbox.UnixMailbox(fp,
> > >email.message_from_file)
|
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 variable the output of
bytesused variable is the below
|
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 tokenize the comma separated values.I used strtok
function reading line by line using fgets.but it gives some weird
behavior.It doesnot stripout the "" fully.Could any body have sample
code for the same so that it will be helfful for my...
| |
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">
<loc>Newport</loc>
|
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 submitting user
information into my creation script, I get the following error from the
page that is suppose to insert the user data into the database, create
a code, then send an email out for verification.
Parse error: parse error, unexpected $end in...
|
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.
who can give me some ideas?
The following is my program, but it has some problem. I hope someone
would correct it.
////////////////////////////
//Test_ConvertArg.c
////////////////////////////
|
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 file. Because I set some properties in parser, which may cause to changes between actual and parsed.
What I expect is the exact XML file structure is to be available into another XML file (incl white spc's) after SAX parsing.
Below is a snippet...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |