Knowing whether a string appears twice or more times

Author Message

Alejandro Serrano

Thursday 21 September 2006 3:50:01 am

Hi,
I need to know whether a string contains two or more ocurrences of another one.
For example, I want to know whether "26, 27, 23, 26" contains one or more times the string "26,". Is there any way to accomplish this task?

Thanks in advance

Claudia Kosny

Friday 22 September 2006 12:54:39 am

Hello Alejandro

As far as I know there is no inbuilt way to do this with EZ. But as there is the PHP function substr_count for this, you just need to write an EZ template operator for this. More info about how to do this is here:

http://ez.no/products/ez_publish/documentation/development/extensions/template_operator

Greetings from Luxembourg

Claudia

Softriva .com

Friday 22 September 2006 1:08:26 am

Up to my humble knowledge, you can solve this in two ways,

A. Write your own operator using php.
B. using the existing operator as follows:
1. explode the string into array1 (see link below)
2. use the unique operator of the array1 to make array2.
3. Compare the two arrays if they are the same then there are no repeated words. If not then you can iterate (may sining foreach) through the two arrays to find the duplicate words

May be someone else can help you better than me. I just tried.

http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:24:40
Script start
Timing: Jan 18 2025 16:24:40
Module start 'layout'
Timing: Jan 18 2025 16:24:40
Module start 'content'
Timing: Jan 18 2025 16:24:41
Module end 'content'
Timing: Jan 18 2025 16:24:41
Script end

Main resources:

Total runtime0.4794 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 595.0313152.6406
Module start 'layout' 0.00500.0023 747.671939.4922
Module start 'content' 0.00730.4707 787.1641501.7891
Module end 'content' 0.47800.0014 1,288.95318.1250
Script end 0.4794  1,297.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.6756160.0002
Check MTime0.00140.2873160.0001
Mysql Total
Database connection0.00100.208810.0010
Mysqli_queries0.437791.2938590.0074
Looping result0.00050.1114570.0000
Template Total0.446993.220.2234
Template load0.00320.658920.0016
Template processing0.443792.545020.2218
Template load and register function0.00020.049610.0002
states
state_id_array0.00160.334510.0016
state_identifier_array0.00090.189820.0005
Override
Cache load0.00240.5088220.0001
Sytem overhead
Fetch class attribute can translate value0.00060.117730.0002
Fetch class attribute name0.00090.189630.0003
XML
Image XML parsing0.00030.060530.0001
class_abstraction
Instantiating content class attribute0.00000.001630.0000
General
dbfile0.00050.1085100.0001
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 11
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs