PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 19th, 2004, 03:17 AM
jocuddy10 jocuddy10 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 jocuddy10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy splitting PHP strings

Hi,
I've recenty transformed some XML with XSL and PHP. as shown in the code below.
Now i need to split the $html string (which is the resultant HTML output of the XML file)
into single characters instead of printing it to screen. Inhave tried the ususal PHP methods for splitting a string, nothing seems to work. I have also tried putting the string into an array. Again, nothing works. Could anyone please help me?

<?php

// Create an XSLT processor
$xsltproc = xslt_create();

// Perform the transformation
$html = xslt_process($xsltproc, 'results1.xml', 'results1.xsl');

// Detect errors
if (!$html) die('XSLT processing error: '.xslt_error($xsltproc));

// Destroy the XSLT processor
xslt_free($xsltproc);
//print out the HTML
echo $html;

?>

Thanks

Jo

Reply With Quote
  #2  
Old August 19th, 2004, 06:21 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Did you try splitting on an empty string? Failing that, you could iterate over the string using strlen() as your counter and strpos() to get the current character.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old August 19th, 2004, 08:06 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 995 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 13 h 57 m 35 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
Why the heck do you want it in single characters?

Whatever, the following function returns an array containing the characters of the inputted string as entries. Hope it helps.

PHP Code:
function str_to_chars($input_string)
{
    
$output_array = array();

    
# first element of output array is amount of characters
    
array_push($output_arraystrlen($input_string));

    
# other elements ($output_array[1] upto and including $output_array[$output_array[0]])
    # are the characters of the string
    
for($i 0$i strlen($input_string); $i++)
        
array_push($output_arraysubstr($input_string$i1));

    return 
$output_array;



Hope it's of use.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > splitting PHP strings


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT