Wants to get a text from source. (Text between 2 words)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zerandib
Forum Newbie
Posts: 16
Joined: Tue Dec 16, 2008 12:17 am

Wants to get a text from source. (Text between 2 words)

Post by zerandib »

Hi,

I want to get a specific word from the source-code

relevant source code is like this;

Code: Select all

    <div class="container_16 marginTB10px">
    						<div id="wow_backtoalldeals">
    							<div id="gobacktoindex" class="grid_15 alpha omega">
    								Looking for the full list of deals?
    								<a href="/deals/home.jsp?atg.multisite.remap=false">Click here</a>	to go back
    							</div>
    							<div class="clear"></div>
    						</div>
    					</div>

    					<div class="clear"></div>

    	</div>
    				<!-- Deal item Block End -->
    			</div>
    			<div class="clear"></div>

    			<div id="addToCartInputs"></div>
    			<script type="text/javascript">

    				$(document).ready(function() {
    					var endDate = "2014-06-06 00:00:00.0";
    					var endDay = new Date(getTimestamp(endDate));
    					$('#countDownTime').countdown({
    						until : endDay,
    						format: 'dHM',
    						layout: '{dnn} Day(s) {hnn} Hour(s) {mnn} Minute(s)  Remaining',
    						expiryText: "Expired"
    					});

    				})
    			var attrNames = '';
    			var attrValues = '';
    			var productId = 'prod1010042';
    			var skuId = '';
    			var qty = '15';
    			function getSkuAttributes(attrName,selectedIndex) {

    				attrNames = '';
    				attrValues = '';
    				skuId = '';
    				$('select[id^=dealoptions]')
    						.each(
    								function(index) {
    									console.log(index + ": "
    											+ $(this).val() + ' '
    											+ $(this).attr('name'));
    									if (index <= selectedIndex) {
    									if (index == 0) {
    										attrNames += $(this).attr(
    												'name');
    										attrValues += $(this).val();
    									} else {
    										attrNames += '~'
    												+ $(this).attr(
    														'name');
    										attrValues += '~'
    												+ $(this).val();
    									}
    									}
    								});
    				callSkuContents();

    			}

From the above source code i want to get this 2014-06-06 00:00:00.0 part.

How can i do this?

I have done like this
-----------

$html2 = str_get_html($mysource);
$value = $html2->find(<<What needs to come here>>)

--------------

Looking forward for your responses

regards,
zerandib
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Wants to get a text from source. (Text between 2 words)

Post by Christopher »

Do you want to find any text formatted like date? Or do you want to find the value of a variable named "endDate" in the source? Or maybe any variable with "Date" in the name?
(#10850)
Post Reply