ends_with ( $value )

Whether or not the current node ends with the compared value.

Access

public

Parameters

Parameter

Type

Required

Description

$value

string

Required

The value to compare the current node to.

Returns

Type

Description

boolean

Whether or not the current node ends with the compared value.

Examples

Comparison functions with CFSimpleXML

A fairly contrived example showing how to use the custom CFSimpleXML comparison functions.

// Create a contrived response object
$response = new stdClass();
$response->body = simplexml_load_file(dirname(dirname(__FILE__)) . '/_cache/describe_images.xml', 'CFSimpleXML');

// Test is()
$result = $response->body->imagesSet->item[0]->imageState->is('available');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->is('foo');
var_dump($result);

// Test contains()
$result = $response->body->imagesSet->item[0]->imageState->contains('ail');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->contains('foo');
var_dump($result);

// Test matches()
$result = $response->body->imagesSet->item[0]->imageState->matches('/a[a-z]*/');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->matches('/z[0-9]*/');
var_dump($result);

// Test starts_with()
$result = $response->body->imagesSet->item[0]->imageState->starts_with('ava');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->starts_with('zzz');
var_dump($result);

// Test ends_with()
$result = $response->body->imagesSet->item[0]->imageState->ends_with('ble');
var_dump($result);
$result = $response->body->imagesSet->item[0]->imageState->ends_with('qqq');
var_dump($result);
Result:
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)

Source

Method defined in utilities/simplexml.class.php | Toggle source view (4 lines) | View on GitHub

public function ends_with($value)
{
    return $this->matches("@$value$@u");
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback