Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > Array and Object
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 18th April 00:22
vamseevan
External User
 
Posts: 1
Default Array and Object


Hello All,

I am having an array structure as displayed below, The title is the
key and value is the simplexmlelementobject.

[Advanced Virtualization Technologies in Workstation 6-20080320 1604]
=> SimpleXMLElement Object
(
[recordingID] => 932467
[hostWebExID] => marketingprograms
[name] => Title
[createTime] => 03/20/2008 09:04:42
[timeZoneID] => 4
[size] => 49.441048
[recordingType] => 0
[duration] => 3218
)


I access the array $this->result["$event->eventName"] = $event;

But I want to decode all the elements of the object using utf8_decode
but still keep the same structure of the array.
what i mean can I do this ?

$this->result["$event->eventName"] = utf_iso($event);

I appreciate if anyone can help me with this.

Thanks
  Reply With Quote


  sponsored links


2 18th April 00:22
eric.butera
External User
 
Posts: 1
Default Array and Object


Can you jump upstream and decode it before you parse the xml?
  Reply With Quote
3 18th April 00:22
vamseevan
External User
 
Posts: 1
Default Array and Object


I cannot do that. because Simple xml element retrieves everything in
UTF8. I need to decode it to latin1 for comparison with another array.

My query still remains the same.
  Reply With Quote
4 18th April 00:22
tedd.sperling
External User
 
Posts: 1
Default Array and Object


Unless there is something here that I don't understand, there is no
decoding UTF-8 to Latin1

Latin1 is a subset of UTF-8 -- what you find (characters) in Latin 1
is the same as in UTF-8.

If you have a code point (character) that lies outside of the range
of Latin 1, then there is no solution.

Cheers,

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote
5 18th April 00:22
vamseevan
External User
 
Posts: 1
Default Array and Object


Well anyways please let me handle the problems with decoding. I just
want to know if there is a way that I could traverse through all the
elements of the simplexmlobject and still keep the same structure of
the array. What I mean is

[Advanced Virtualization Technologies in Workstation 6-20080320 1604]
=> SimpleXMLElement Object
(
[recordingID] => 932467
[hostWebExID] => marketingprograms
[name] => Title
[createTime] => 03/20/2008 09:04:42
[timeZoneID] => 4
[size] => 49.441048
[recordingType] => 0
[duration] => 3218
)

Go through all the elements of the object and do some encoding and get
back the same array structure.

In raw terms I need to know the procedure that does this and still
keep the same structure of the array.

[Advanced Virtualization Technologies in Workstation 6-20080320 1604]
=> SimpleXMLElement Object
(
[recordingID] => utf8_decode(932467)
[hostWebExID] => utf8_decode(marketingprograms)
[name] => utf8_decode(Title)
[createTime] => utf8_decode(03/20/2008 09:04:42)
[timeZoneID] => utf8_decode(4)
[size] => utf8_decode(49.441048)
[recordingType] => utf8_decode(0)
[duration] => utf8_decode(3218)
)
  Reply With Quote
6 18th April 00:22
tedd.sperling
External User
 
Posts: 1
Default Array and Object


I'm not stopping you.

When you figure out how to decode UTF-8 to Latin, I would like to see it.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote
7 18th April 00:22
topnotcher
External User
 
Posts: 1
Default Array and Object


That top post was totally not I... It was my roommate playing with my
computer *nods*.
  Reply With Quote
8 18th April 00:22
topnotcher
External User
 
Posts: 1
Default Array and Object


Take a look at array_walk(), array_walk_recursive(), array_map() in the PHP
manual.
  Reply With Quote
9 18th April 01:40
quickshiftin
External User
 
Posts: 1
Default Array and Object


first of all, SimpleXMLElement is not an array, its a class. It does
support iteration via the foreach construct though. the foreach iteration
will only go through the first set of elements in the structure, that is it
will only cover the children of the root element. if you want to traverse
all elements of the structure recursively, use SimpleXMLIterator (and
RecursiveIteratorIterator) from SPL.

heres a simple xample to get you started: <?php
$xml = '<m><a><b/></a><c/></m>'; $m = new SimpleXMLElement($xml);
foreach($m as $k => $v) { echo "k:$k => v:$v" . PHP_EOL; } /* outputs
k:a => v:
k:c => v:
*/
$m = new SimpleXMLIterator($xml); foreach(new RecursiveIteratorIterator($m,
RecursiveIteratorIterator::CHILD_FIRST) as $k => $v) { echo "k:$k => v:$v" . PHP_EOL; } /* outputs
k:b => v:
k:a => v:
k:c => v:
*/
-nathan
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666