Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Variable Data Mystery
Old 03-30-2010, 01:55 PM Variable Data Mystery
Junior Talker

Posts: 2
Trades: 0
Ok, this is the oddest thing i have encountered.

I am working on a CMS that provides a template token which renders out some html. I want to obtain that html into a variable and have my way with it. So, im thinking ob_start etc.

Here's the situation:

The template token: [special_section:edition_index]

This renders:
Code:
<a href="/special_section/4/">Answer Book</a><br/><br/>
<a href="/special_section/9/">Home Experts</a><br/><br/>
<a href="/special_section/11/">Young at Heart</a><br/><br/>
<a href="/special_section/28/">Bridal</a><br/><br/>
<a href="/special_section/29/">Complete Wellness</a><br/><br/>
<a href="/special_section/31/">Parade of Homes</a><br/><br/>
<a href="/special_section/37/">Summer Camp</a><br/><br/>
<a href="/special_section/38/">Recreation Services</a><br/><br/>
Here is ALL OF THE CODE:

PHP Code:
<?php  ob_start(); ?>
[special_section:edition_index]
<?php 
$data
=ob_get_contents();
ob_end_clean();

echo 
'DATA: ';
echo 
$data;

preg_match_all('/./'$data$matches);
print_r($matches);
Which then outputs:
Code:
DATA: <a href="/special_section/4/">Answer Book</a><br/><br/>
<a href="/special_section/9/">Home Experts</a><br/><br/>
<a href="/special_section/11/">Young at Heart</a><br/><br/>
<a href="/special_section/28/">Bridal</a><br/><br/>
<a href="/special_section/29/">Complete Wellness</a><br/><br/>
<a href="/special_section/31/">Parade of Homes</a><br/><br/>
<a href="/special_section/37/">Summer Camp</a><br/><br/>
<a href="/special_section/38/">Recreation Services</a><br/><br/>

Array
(
    [0] => Array
        (
            [0] =>     
            [1] =>     
            [2] => [
            [3] => s
            [4] => p
            [5] => e
            [6] => c
            [7] => i
            [8] => a
            [9] => l
            [10] => _
            [11] => s
            [12] => e
            [13] => c
            [14] => t
            [15] => i
            [16] => o
            [17] => n
            [18] => :
            [19] => e
            [20] => d
            [21] => i
            [22] => t
            [23] => i
            [24] => o
            [25] => n
            [26] => _
            [27] => i
            [28] => n
            [29] => d
            [30] => e
            [31] => x
            [32] => ]
            [33] =>     
            [34] =>     
        )
)
How in the heck is my $data var showing me one thing when I echo it out, then as soon as I add it to preg_match_all() it reverts to something else????

Any thoughts anyone?

Thanks.
infekt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-30-2010, 06:58 PM Re: Variable Data Mystery
Junior Talker

Posts: 2
Trades: 0
In case any one was curious...
http://www.codingforums.com/showthread.php?t=192695
infekt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Variable Data Mystery
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22538 seconds with 12 queries